Method: Configuration::ClassMethods#for

Defined in:
lib/configuration.rb

#for(name, options = nil, &block) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/configuration.rb', line 17

def for name, options = nil, &block
  name = name.to_s
  options = options.to_hash if options.is_a?( Configuration )

  if Table.has_key?(name)
    if options or block
      configuration = Table[name]
      Table[name] = DSL.evaluate(configuration, options || {}, &block)
    else
      Table[name]
    end
  else
    if options or block
      Table[name] = new name, options || {}, &block
    else
      load name
    end
  end
end