Class: Kinko::Configuration
- Inherits:
-
Object
- Object
- Kinko::Configuration
- Defined in:
- lib/kinko/configuration.rb
Constant Summary collapse
- KEY_BYTES =
32
Instance Attribute Summary collapse
-
#key_version ⇒ Object
Returns the value of attribute key_version.
-
#keys ⇒ Object
Returns the value of attribute keys.
Instance Method Summary collapse
- #current_key ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #key_for(version) ⇒ Object
- #require! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 |
# File 'lib/kinko/configuration.rb', line 9 def initialize @keys = {} @key_version = nil end |
Instance Attribute Details
#key_version ⇒ Object
Returns the value of attribute key_version.
7 8 9 |
# File 'lib/kinko/configuration.rb', line 7 def key_version @key_version end |
#keys ⇒ Object
Returns the value of attribute keys.
7 8 9 |
# File 'lib/kinko/configuration.rb', line 7 def keys @keys end |
Instance Method Details
#current_key ⇒ Object
22 23 24 25 |
# File 'lib/kinko/configuration.rb', line 22 def current_key require! keys.fetch(key_version) end |
#key_for(version) ⇒ Object
27 28 29 |
# File 'lib/kinko/configuration.rb', line 27 def key_for(version) keys[version] || raise(UnknownKeyVersion, version) end |
#require! ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/kinko/configuration.rb', line 31 def require! raise ConfigurationError, "at least one key must be configured" if keys.empty? raise ConfigurationError, "key_version must be set" if key_version.nil? return if keys.key?(key_version) raise ConfigurationError, "key_version #{key_version.inspect} is not present in keys" end |