class SignedGlobalID

Overview

Ported from Rails GlobalID SignedGlobalID semantics with Crystal adaptations. Upstream reference: https://github.com/rails/globalid/blob/main/lib/global_id/signed_global_id.rb Rails example SignedGlobalID.verifier.instance_variable_get(:@digest) # => "SHA1" SignedGlobalID.verifier.instance_variable_get(:@secret).bytes.join(",") # => "SHA1"

Defined in:

global_id/signed_global_id.cr

Constant Summary

DEFAULT_PURPOSE = "default"

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(gid : URI | String, verifier : ActiveSupport::MessageVerifier | Nil = nil, purpose : String = DEFAULT_PURPOSE, expires_at : ExpirationAtOption = ExpirationNotSet.new, expires_in : ExpiresInOption = ExpirationNotSet.new) #

Class Method Detail

def self.create(gid : URI | String, verifier : ActiveSupport::MessageVerifier | Nil = nil, purpose : String = DEFAULT_PURPOSE, expires_at : ExpirationAtOption = ExpirationNotSet.new, expires_in : ExpiresInOption = ExpirationNotSet.new) #

def self.expires_in : Time::Span | Nil #

def self.expires_in=(value : Time::Span | Nil) #

def self.locate(sgid : String, verifier : ActiveSupport::MessageVerifier | Nil = nil, purpose : String = DEFAULT_PURPOSE, & : String, String, String, Hash(String, String) -> T) : T | Nil forall T #

def self.parse(sgid : String, verifier : ActiveSupport::MessageVerifier | Nil = nil, purpose : String = DEFAULT_PURPOSE) : self | Nil #

def self.pick_verifier(verifier : ActiveSupport::MessageVerifier | Nil) : ActiveSupport::MessageVerifier #

def self.verifier : ActiveSupport::MessageVerifier | Nil #

def self.verifier=(value : ActiveSupport::MessageVerifier | Nil) #

Instance Method Detail

def ==(other) #
Description copied from class Reference

Returns false (other can only be a Value here).


def app : String #

def expires_at : Time | Nil #

def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def inspect #

Keep Rails-style inspect parity and avoid exposing SGID payload internals in debug logs.


def locate(& : String, String, String, Hash(String, String) -> T) : T forall T #

def model_id : String #

def model_name : String #

def params : Hash(String, String) #

def purpose : String #

def to_param #

def to_s #
Description copied from class Object

Returns a nicely readable and concise string representation of this object, typically intended for users.

This method should usually not be overridden. It delegates to #to_s(IO) which can be overridden for custom implementations.

Also see #inspect.


def uri : URI #