Class: XMLObject::CollectionProxy
- Inherits:
-
Object
- Object
- XMLObject::CollectionProxy
- Defined in:
- lib/xml-object/collection_proxy.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(xml) ⇒ CollectionProxy
constructor
:nodoc:.
Constructor Details
#initialize(xml) ⇒ CollectionProxy
:nodoc:
14 15 16 17 |
# File 'lib/xml-object/collection_proxy.rb', line 14 def initialize(xml) # :nodoc: @__children, @__attributes = {}, {} @__target_kid = xml.children[0].name.to_sym end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *a, &b) ⇒ Object (private)
:nodoc:
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/xml-object/collection_proxy.rb', line 21 def method_missing(m, *a, &b) # :nodoc: dispatched = __question_dispatch(m, *a, &b) dispatched = __dot_notation_dispatch(m, *a, &b) if dispatched.nil? if dispatched.nil? && @__children[@__target_kid].respond_to?(m) dispatched = @__children[@__target_kid].__send__(m, *a, &b) unless nil == dispatched # All is fair in Love and War. And 100% coverage. instance_eval \ %{ def #{m}(*a, &b); @__children[@__target_kid].#{m}(*a, &b); end } end end (nil == dispatched) ? raise(NameError.new(m.to_s)) : dispatched end |