Class: Amrita2::HashDelegator
- Includes:
- DictionaryData
- Defined in:
- lib/amrita2/template.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #id ⇒ Object
-
#initialize(parent, &block) ⇒ HashDelegator
constructor
A new instance of HashDelegator.
- #method_missing(sym, *args, &block) ⇒ Object
Methods included from DictionaryData
Constructor Details
#initialize(parent, &block) ⇒ HashDelegator
Returns a new instance of HashDelegator.
2568 2569 2570 2571 2572 |
# File 'lib/amrita2/template.rb', line 2568 def initialize(parent, &block) @parent = parent @added_data = block.call raise 'block did not return a Hash' unless @added_data.kind_of?(DictionaryData) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 |
# File 'lib/amrita2/template.rb', line 2584 def method_missing(sym, *args, &block) if @added_data.has_key?(sym) @added_data[sym] else if @parent.kind_of?(DictionaryData) @parent.amrita_value(sym) else @parent.send(sym) end end end |