Class: Kitsune::Kit::Adapters::FakeSecretStore
- Inherits:
-
SecretStores::Store
- Object
- SecretStores::Store
- Kitsune::Kit::Adapters::FakeSecretStore
- Defined in:
- lib/kitsune/kit/adapters/fake_secret_store.rb
Instance Attribute Summary collapse
-
#fetches ⇒ Object
readonly
Returns the value of attribute fetches.
Instance Method Summary collapse
- #configured?(name) ⇒ Boolean
- #fetch(name, required: true) ⇒ Object
-
#initialize(values = {}) ⇒ FakeSecretStore
constructor
A new instance of FakeSecretStore.
- #set(name, value) ⇒ Object
Constructor Details
#initialize(values = {}) ⇒ FakeSecretStore
Returns a new instance of FakeSecretStore.
12 13 14 15 16 |
# File 'lib/kitsune/kit/adapters/fake_secret_store.rb', line 12 def initialize(values = {}) super() @values = values.transform_keys(&:to_s) @fetches = [] end |
Instance Attribute Details
#fetches ⇒ Object (readonly)
Returns the value of attribute fetches.
10 11 12 |
# File 'lib/kitsune/kit/adapters/fake_secret_store.rb', line 10 def fetches @fetches end |
Instance Method Details
#configured?(name) ⇒ Boolean
30 |
# File 'lib/kitsune/kit/adapters/fake_secret_store.rb', line 30 def configured?(name) = !@values.fetch(name.to_s, "").empty? |
#fetch(name, required: true) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/kitsune/kit/adapters/fake_secret_store.rb', line 18 def fetch(name, required: true) key = name.to_s @fetches << key value = @values.fetch(key, "") if required && value.empty? raise Errors::ConfigurationError.new( "required secret #{key} is not set", hint: "Provide #{key} through the configured secret store." ) end value end |
#set(name, value) ⇒ Object
31 |
# File 'lib/kitsune/kit/adapters/fake_secret_store.rb', line 31 def set(name, value) = @values[name.to_s] = value.to_s |