Class: Tzispa::Rig::LoopBinder
- Defined in:
- lib/tzispa/rig/binder.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Attributes inherited from Binder
#context, #data_struct, #parser
Instance Method Summary collapse
- #bind!(&generator) ⇒ Object
- #loop_item(params = nil) ⇒ Object
- #method_missing(method, *args, &generator) ⇒ Object
Methods inherited from Binder
Constructor Details
This class inherits a constructor from Tzispa::Rig::Binder
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &generator) ⇒ Object
105 106 107 |
# File 'lib/tzispa/rig/binder.rb', line 105 def method_missing(method, *args, &generator) @source_object.send method, *args, &generator end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
97 98 99 |
# File 'lib/tzispa/rig/binder.rb', line 97 def data @data end |
Instance Method Details
#bind!(&generator) ⇒ Object
99 100 101 102 103 |
# File 'lib/tzispa/rig/binder.rb', line 99 def bind!(&generator) @source_object = eval "self", generator.binding @data = instance_eval(&generator).to_enum(:each) self end |
#loop_item(params = nil) ⇒ Object
109 110 111 112 113 114 115 116 |
# File 'lib/tzispa/rig/binder.rb', line 109 def loop_item(params=nil) (LoopItem.new self).tap { |item| params.each{ |k,v| raise UnknownTag.new "#{k} is not a tag in #{self.class.name}" unless .include? k item.data[k] = v } if params } end |