Class: Representable::XML::AttributeHashBinding

Inherits:
CollectionBinding show all
Defined in:
lib/representable/bindings/xml_bindings.rb

Instance Attribute Summary

Attributes inherited from Binding

#definition

Instance Method Summary collapse

Methods inherited from CollectionBinding

#serialize_for

Methods inherited from PropertyBinding

#deserialize_node, #initialize, #read, #serialize_for, #serialize_node

Methods inherited from Binding

#deserialize, #initialize, #serialize

Constructor Details

This class inherits a constructor from Representable::XML::PropertyBinding

Instance Method Details

#deserialize_from(node) ⇒ Object



128
129
130
131
132
133
134
# File 'lib/representable/bindings/xml_bindings.rb', line 128

def deserialize_from(node)
  {}.tap do |hash|
    node.each do |k,v|
      hash[k] = deserialize(v)
    end
  end
end

#write(parent, value) ⇒ Object

DISCUSS: use AttributeBinding here?



121
122
123
124
125
126
# File 'lib/representable/bindings/xml_bindings.rb', line 121

def write(parent, value)  # DISCUSS: is it correct overriding #write here?
  value.collect do |k, v|
    parent[k] = serialize(v.to_s)
  end
  parent
end