Class: Configus::Proxy
- Inherits:
-
Object
- Object
- Configus::Proxy
- Defined in:
- lib/configus/proxy.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(block) ⇒ Proxy
constructor
A new instance of Proxy.
- #method_missing(key, value = nil, &block) ⇒ Object
Constructor Details
#initialize(block) ⇒ Proxy
Returns a new instance of Proxy.
12 13 14 15 |
# File 'lib/configus/proxy.rb', line 12 def initialize(block) @result = {} instance_eval &block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(key, value = nil, &block) ⇒ Object
17 18 19 |
# File 'lib/configus/proxy.rb', line 17 def method_missing(key, value = nil, &block) @result[key] = block_given? ? self.class.generate(block) : value end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
3 4 5 |
# File 'lib/configus/proxy.rb', line 3 def result @result end |
Class Method Details
.generate(block) ⇒ Object
6 7 8 9 |
# File 'lib/configus/proxy.rb', line 6 def generate(block) p = new(block) p.result end |