Class: Populus::Configuration
- Inherits:
-
Object
- Object
- Populus::Configuration
- Defined in:
- lib/populus/configuration.rb
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #method_missing(meth, *args) ⇒ Object
- #set(key, value) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
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
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 |