Class: VfrUtils::MasterConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/vfr_utils/master_configuration.rb

Instance Method Summary collapse

Constructor Details

#initialize(defaults = {}) ⇒ MasterConfiguration

Returns a new instance of MasterConfiguration.


4
5
6
7
# File 'lib/vfr_utils/master_configuration.rb', line 4

def initialize(defaults={})
  @defaults = defaults
  @modules = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &blk) ⇒ Object


9
10
11
12
13
14
15
16
17
# File 'lib/vfr_utils/master_configuration.rb', line 9

def method_missing(method_name, *args, &blk)
  unless @modules[method_name]
    @modules[method_name] = Configuration.new @defaults
    self.class.class_exec do
      define_method(method_name) { @modules[method_name] }
    end
    send(method_name, *args, &blk)
  end
end

Instance Method Details

#global(values) ⇒ Object


19
20
21
22
23
24
25
26
27
# File 'lib/vfr_utils/master_configuration.rb', line 19

def global(values)
  @defaults.merge! values
  @modules.each_value do |m|
    values.each_pair do |k,v|
      key = "#{k}=".to_sym
      m.send(key, v)
    end
  end
end