module DhEasy::Core::Plugin::ConfigBehavior

Attributes

config_collection_key[R]

Public Instance Methods

config_collection() click to toggle source

Get config collection name. @return [String]

# File lib/dh_easy/core/plugin/config_behavior.rb, line 26
def config_collection
  collections[config_collection_key]
end
find_config(key) click to toggle source

Find a configuration value by item key.

@param [Symbol] key Item key to find.

@note Instance must implement:

* `find_output(collection, query)`
# File lib/dh_easy/core/plugin/config_behavior.rb, line 36
def find_config key
  value = find_output config_collection, '_id' => key
  value ||= {'_collection' => config_collection, '_id' => key}
end
initialize_hook_core_config_behavior(opts = {}) click to toggle source

Hook to map config behavior on self

@param [Hash] opts ({}) Configuration options. @option opts [Array] :config_collection ([:config, 'config']) Key value pair array to se a custom collection.

@example

initialize_hook_core_config_behavior config_collection: [:my_config, 'abc']
config_collection
# => 'abc'
# File lib/dh_easy/core/plugin/config_behavior.rb, line 19
def initialize_hook_core_config_behavior opts = {}
  @config_collection_key, collection = opts[:config_collection] || [:config, 'config']
  add_collection config_collection_key, collection
end