Class: Toktok::Configuration
- Inherits:
-
Object
- Object
- Toktok::Configuration
- Defined in:
- lib/toktok/configuration.rb
Constant Summary collapse
- SecretKeyMissingError =
Error raised when an algorithm is given but the secret_key is missing.
Class.new(StandardError)
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
readonly
Returns the value of attribute algorithm.
-
#lifetime ⇒ Object
readonly
Returns the value of attribute lifetime.
-
#secret_key ⇒ Object
readonly
Returns the value of attribute secret_key.
Instance Method Summary collapse
-
#initialize(algorithm: nil, lifetime: nil, secret_key: nil) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(algorithm: nil, lifetime: nil, secret_key: nil) ⇒ Configuration
Returns a new instance of Configuration.
8 9 10 11 12 13 14 15 16 |
# File 'lib/toktok/configuration.rb', line 8 def initialize(algorithm: nil, lifetime: nil, secret_key: nil) @algorithm = algorithm || 'HS256' @lifetime = lifetime @secret_key = secret_key if algorithm != 'none' && (secret_key || '') == '' raise SecretKeyMissingError, "Toktok: The algorithm #{algorithm} requires you to setup a 'secret_key'" end end |
Instance Attribute Details
#algorithm ⇒ Object (readonly)
Returns the value of attribute algorithm.
3 4 5 |
# File 'lib/toktok/configuration.rb', line 3 def algorithm @algorithm end |
#lifetime ⇒ Object (readonly)
Returns the value of attribute lifetime.
3 4 5 |
# File 'lib/toktok/configuration.rb', line 3 def lifetime @lifetime end |
#secret_key ⇒ Object (readonly)
Returns the value of attribute secret_key.
3 4 5 |
# File 'lib/toktok/configuration.rb', line 3 def secret_key @secret_key end |