Class: Logging::Config::Configurator::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/logging/config/configurator.rb

Direct Known Subclasses

TopLevelDSL

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



147
148
149
150
151
152
153
# File 'lib/logging/config/configurator.rb', line 147

def method_missing( method, *args, &block )
  args << DSL.process(&block) if block

  key = method.to_sym
  value = (1 == args.length ? args.first : args)
  __store(key, value)
end

Class Method Details

.process(&block) ⇒ Object



137
138
139
140
141
# File 'lib/logging/config/configurator.rb', line 137

def self.process( &block )
  dsl = new
  dsl.instance_eval(&block)
  dsl.__hash
end

Instance Method Details

#__hashObject



143
144
145
# File 'lib/logging/config/configurator.rb', line 143

def __hash
  @hash ||= Hash.new
end

#__store(key, value) ⇒ Object



155
156
157
# File 'lib/logging/config/configurator.rb', line 155

def __store( key, value )
  __hash[key] = value
end