Class: Populus::Configuration

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

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



5
6
7
# File 'lib/populus/configuration.rb', line 5

def initialize
  @pool = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object

Raises:

  • (NameError)


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

def method_missing(meth, *args)
  raise NameError, "Populus::Configuration value #{meth} is not yet defined"
end

Instance Method Details

#set(key, value) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/populus/configuration.rb', line 9

def set(key, value)
  true_value = case value
               when Proc
                 value
               else
                 lambda { value }
               end
  self.define_singleton_method key do
    @pool[key] || (
      @pool[key] = true_value.call
    )
  end
end