Class: Knowledge::Adapters::KeyValue

Inherits:
Base
  • Object
show all
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

File

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Knowledge::Adapters::Base

Instance Attribute Details

#setterClass (readonly)

Returns the current value of setter.

Returns:

  • (Class)

    the current value of setter



28
29
30
# File 'lib/knowledge/adapters/key_value.rb', line 28

def setter
  @setter
end

#variablesHash (readonly)

Returns the current value of variables.

Returns:

  • (Hash)

    the current value of variables



28
29
30
# File 'lib/knowledge/adapters/key_value.rb', line 28

def variables
  @variables
end

Instance Method Details

#runObject

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