Class: Waw::Config::DSL

Inherits:
Object show all
Defined in:
lib/waw/config.rb

Overview

Implementation of the config domain specific language

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ DSL

Creates a DSL instance



9
10
11
# File 'lib/waw/config.rb', line 9

def initialize(config)
  @config = config
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

When a method is missing, install config parameter



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/waw/config.rb', line 14

def method_missing(name, *args, &block)
  if args.length==0 and block.nil?
    @config.send(name)
  elsif args.length==0
    @config.install_configuration_property(name, block)
  elsif block
    raise WawConfigurationError, "Bad config usage on #{name}"
  else
    @config.install_configuration_property(name, args.size==1 ? args[0] : args)
  end
end