Class: Sc4ry::Config::ConfigMapper

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

Instance Method Summary collapse

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)

Parameters:

  • definition (Hash) (defaults to: DEFAULT_CONFIG)

    a config hash



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

#configObject (readonly)

config from given definition passed in constructor



80
81
82
# File 'lib/sc4ry/config.rb', line 80

def config
  @config
end