Module: AeEasy::Core::Plugin::ConfigBehavior

Includes:
CollectionVault, ContextIntegrator
Included in:
Config
Defined in:
lib/ae_easy/core/plugin/config_behavior.rb

Instance Attribute Summary collapse

Attributes included from ContextIntegrator

#context

Instance Method Summary collapse

Methods included from CollectionVault

#add_collection, #collections

Methods included from ContextIntegrator

#initialize_hook_core_context_integrator, #mock_context

Instance Attribute Details

#config_collection_keyObject (readonly)

Returns the value of attribute config_collection_key



5
6
7
# File 'lib/ae_easy/core/plugin/config_behavior.rb', line 5

def config_collection_key
  @config_collection_key
end

Instance Method Details

#config_collectionString

Get config collection name.

Returns:

  • (String)


26
27
28
# File 'lib/ae_easy/core/plugin/config_behavior.rb', line 26

def config_collection
  collections[config_collection_key]
end

#find_config(key) ⇒ Object

Note:

Instance must implement:

  • `find_output(collection, query)`

Find a configuration value by item key.

Parameters:

  • key (Symbol)

    Item key to find.



36
37
38
39
# File 'lib/ae_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 = {}) ⇒ Object

Hook to map config behavior on self

Examples:

initialize_hook_core_config_behavior config_collection: [:my_config, 'abc']
config_collection
# => 'abc'

Parameters:

  • opts (Hash) (defaults to: {})

    ({}) Configuration options.

Options Hash (opts):

  • :config_collection (Array) — default: [:config, 'config']

    Key value pair array to se a custom collection.



19
20
21
22
# File 'lib/ae_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