Class: Configurer::Config
- Inherits:
-
Module
- Object
- Module
- Configurer::Config
- Defined in:
- lib/configurer.rb
Instance Attribute Summary collapse
-
#arr ⇒ Object
Returns the value of attribute arr.
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, &blk) ⇒ Object
9 |
# File 'lib/configurer.rb', line 9 def method_missing(sym, &blk); arr.first[sym] = blk; end |
Instance Attribute Details
#arr ⇒ Object
Returns the value of attribute arr.
8 9 10 |
# File 'lib/configurer.rb', line 8 def arr @arr end |
Instance Method Details
#[]=(sym, blk) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/configurer.rb', line 10 def []=(sym, blk) (arr = self.arr).last[sym] = blk define_method sym do frame = Module===self ? self : self.class blk = arr.inject(nil){ |m, e| m || e[sym] } frame.instance_eval(&blk) end end |