Module: Representable::XML::ClassMethods
- Defined in:
- lib/representable/xml.rb
Instance Method Summary collapse
- #binding_for_definition(definition) ⇒ Object
- #definition_class ⇒ Object
-
#from_xml(doc, *args, &block) ⇒ Object
Creates a new Ruby object from XML using mapping information declared in the class.
Instance Method Details
#binding_for_definition(definition) ⇒ Object
30 31 32 |
# File 'lib/representable/xml.rb', line 30 def binding_for_definition(definition) (BINDING_FOR_TYPE[definition.sought_type] or ObjectBinding).new(definition) end |
#definition_class ⇒ Object
26 27 28 |
# File 'lib/representable/xml.rb', line 26 def definition_class Definition end |
#from_xml(doc, *args, &block) ⇒ Object
Creates a new Ruby object from XML using mapping information declared in the class.
Accepts a block yielding the currently iterated Definition. If the block returns false the property is skipped.
Example:
band.from_xml("
41 42 43 44 45 |
# File 'lib/representable/xml.rb', line 41 def from_xml(doc, *args, &block) create_from_xml(*args).tap do |object| object.from_xml(doc, *args, &block) end end |