Method: Configuration::DSL#method_missing

Defined in:
lib/configuration.rb

#method_missing(m, *a, &b) ⇒ Object



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/configuration.rb', line 157

def method_missing(m, *a, &b)
  if(a.empty? and b.nil?)
    return Pure[@__configuration].send(m, *a, &b)
  end
  if b
    raise ArgumentError unless a.empty?
    parent = @__configuration
    name = m.to_s
    configuration =
      if @__configuration.respond_to?(name) and Configuration === @__configuration.send(name)
        @__configuration.send name 
      else
        Configuration.new name
      end
    Pure[configuration].instance_eval{ @__parent = parent }
    DSL.evaluate configuration, &b
    value = configuration
  end
  unless a.empty?
    value = a.size == 1 ? a.first : a
  end
  @__singleton_class.module_eval do
    define_method(m){ value }
  end
end