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

Inherits:
Object
  • Object
show all
Defined in:
lib/gems/logging-0.9.4/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



149
150
151
152
153
154
155
# File 'lib/gems/logging-0.9.4/lib/logging/config/configurator.rb', line 149

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



139
140
141
142
143
# File 'lib/gems/logging-0.9.4/lib/logging/config/configurator.rb', line 139

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

Instance Method Details

#__hashObject



145
146
147
# File 'lib/gems/logging-0.9.4/lib/logging/config/configurator.rb', line 145

def __hash
  @hash ||= Hash.new
end

#__store(key, value) ⇒ Object



157
158
159
# File 'lib/gems/logging-0.9.4/lib/logging/config/configurator.rb', line 157

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