Class: Knowledge::Adapters::KeyValue
- Defined in:
- lib/knowledge/adapters/key_value.rb
Overview
Description
This adapter takes some vars in a config object and put it in your project’s config. The config object should provide a hash with key=value format.
Usage
@example:
# Define your vars with the name of the variable as key and the value as value
my_vars = { application_token: 's3cret', aws_secret: 's3cret' }
# Instanciate the adapter
adapter = Knowledge::Adapters::KeyValue.new(setter: MySetter, variables: my_vars)
# And run it
adapter.run
Attributes
Direct Known Subclasses
Instance Attribute Summary collapse
-
#setter ⇒ Class
readonly
The current value of setter.
-
#variables ⇒ Hash
readonly
The current value of variables.
Instance Method Summary collapse
-
#run ⇒ Object
Runs the actual adapter.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Knowledge::Adapters::Base
Instance Attribute Details
#setter ⇒ Class (readonly)
Returns the current value of setter.
28 29 30 |
# File 'lib/knowledge/adapters/key_value.rb', line 28 def setter @setter end |
#variables ⇒ Hash (readonly)
Returns the current value of variables.
28 29 30 |
# File 'lib/knowledge/adapters/key_value.rb', line 28 def variables @variables end |
Instance Method Details
#run ⇒ Object
Runs the actual adapter.
34 35 36 |
# File 'lib/knowledge/adapters/key_value.rb', line 34 def run variables.each { |name, value| setter.set(name: name, value: value) } end |