Class: Sc4ry::Config::ConfigMapper
- Inherits:
-
Object
- Object
- Sc4ry::Config::ConfigMapper
- Includes:
- Sc4ry::Constants
- Defined in:
- lib/sc4ry/config.rb
Overview
Note:
work for/with Sc4ry::Circuits.configure and Sc4ry::Circuits.register when block given
Config Data mapper for block yielding methods for configuration
Constant Summary
Constants included from Sc4ry::Constants
Sc4ry::Constants::CURRENT_NOTIFIERS, Sc4ry::Constants::DEFAULT_CONFIG, Sc4ry::Constants::DEFAULT_CONFIG_FORMATS
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
config from given definition passed in constructor.
Instance Method Summary collapse
-
#initialize(definition: DEFAULT_CONFIG) ⇒ ConfigMapper
constructor
the mapping constructor from a given definition or the default From Sc4ry config (Constant).
Constructor Details
#initialize(definition: DEFAULT_CONFIG) ⇒ ConfigMapper
Note:
creating dynamically accessors on config record given in definition
the mapping constructor from a given definition or the default From Sc4ry config (Constant)
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/sc4ry/config.rb', line 85 def initialize(definition: DEFAULT_CONFIG) @config = definition @config.each do |key, _value| define_singleton_method "#{key}=".to_sym do |val| key = __method__.to_s.chop.to_sym @config[key] = val end define_singleton_method key do return @config[__method__] end end end |
Instance Attribute Details
#config ⇒ Object (readonly)
config from given definition passed in constructor
80 81 82 |
# File 'lib/sc4ry/config.rb', line 80 def config @config end |