Class: Representable::XML::HashBinding
- Inherits:
-
CollectionBinding
- Object
- Binding
- PropertyBinding
- CollectionBinding
- Representable::XML::HashBinding
- Defined in:
- lib/representable/bindings/xml_bindings.rb
Instance Attribute Summary
Attributes inherited from Binding
Instance Method Summary collapse
Methods inherited from PropertyBinding
build_for, #deserialize_method, #read, #serialize_method, #serialize_node, #write
Methods included from Binding::Object
#create_object, #deserialize, #serialize
Methods inherited from Binding
#as, build, #compile_fragment, #get, #initialize, #parse_filter, #read_fragment, #read_fragment_for, #render_filter, #representer_module_for, #set, #uncompile_fragment, #write_fragment, #write_fragment_for
Constructor Details
This class inherits a constructor from Representable::Binding
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Representable::Binding
Instance Method Details
#deserialize_from(nodes) ⇒ Object
114 115 116 117 118 119 120 |
# File 'lib/representable/bindings/xml_bindings.rb', line 114 def deserialize_from(nodes) {}.tap do |hash| nodes.children.each do |node| hash[node.name] = deserialize(content_for node) end end end |
#serialize_for(value, parent) ⇒ Object
107 108 109 110 111 112 |
# File 'lib/representable/bindings/xml_bindings.rb', line 107 def serialize_for(value, parent) set_for(parent, value.collect do |k, v| node = node_for(parent, k) serialize_node(node, v) end) end |