Class: Webgen::Configuration::MethodChain

Inherits:
Object
  • Object
show all
Defined in:
lib/webgen/configuration.rb

Overview

Helper class for providing an easy method to define configuration options.

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ MethodChain

:nodoc:



23
24
25
26
# File 'lib/webgen/configuration.rb', line 23

def initialize(config) #:nodoc:
  @config = config
  @name = ''
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id, *args) ⇒ Object

:nodoc:



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/webgen/configuration.rb', line 28

def method_missing(id, *args) #:nodoc:
  @name += (@name.empty? ? '' : '.') + id.id2name.sub(/(!|=)$/,'')
  if args.length > 0
    value = args.shift
    @config.data[@name] = value unless @config.data.has_key?(@name) # value is set only the first time
    @config.meta_info[@name] ||= {}
    @config.meta_info[@name].update(*args) if args.length > 0
    nil
  else
    self
  end
end