Class: JWT::JWK::KeyBase
- Inherits:
-
Object
- Object
- JWT::JWK::KeyBase
- Defined in:
- lib/jwt/jwk/key_base.rb
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #hash ⇒ Object
-
#initialize(options, params = {}) ⇒ KeyBase
constructor
A new instance of KeyBase.
- #kid ⇒ Object
Constructor Details
#initialize(options, params = {}) ⇒ KeyBase
Returns a new instance of KeyBase.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/jwt/jwk/key_base.rb', line 11 def initialize(, params = {}) ||= {} @parameters = params.transform_keys(&:to_sym) # Uniform interface # For backwards compatibility, kid_generator may be specified in the parameters [:kid_generator] ||= @parameters.delete(:kid_generator) # Make sure the key has a kid kid_generator = [:kid_generator] || ::JWT.configuration.jwk.kid_generator self[:kid] ||= kid_generator.new(self).generate end |
Class Method Details
Instance Method Details
#<=>(other) ⇒ Object
46 47 48 49 50 |
# File 'lib/jwt/jwk/key_base.rb', line 46 def <=>(other) return nil unless other.is_a?(::JWT::JWK::KeyBase) self[:kid] <=> other[:kid] end |
#==(other) ⇒ Object Also known as: eql?
40 41 42 |
# File 'lib/jwt/jwk/key_base.rb', line 40 def ==(other) other.is_a?(::JWT::JWK::KeyBase) && self[:kid] == other[:kid] end |
#[](key) ⇒ Object
32 33 34 |
# File 'lib/jwt/jwk/key_base.rb', line 32 def [](key) @parameters[key.to_sym] end |
#[]=(key, value) ⇒ Object
36 37 38 |
# File 'lib/jwt/jwk/key_base.rb', line 36 def []=(key, value) @parameters[key.to_sym] = value end |
#hash ⇒ Object
28 29 30 |
# File 'lib/jwt/jwk/key_base.rb', line 28 def hash self[:kid].hash end |
#kid ⇒ Object
24 25 26 |
# File 'lib/jwt/jwk/key_base.rb', line 24 def kid self[:kid] end |