Class: Representable::XML::AttributeHashBinding

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

Instance Attribute Summary

Attributes inherited from Binding

#represented, #user_options

Instance Method Summary collapse

Methods inherited from CollectionBinding

#serialize_for

Methods inherited from PropertyBinding

build_for, #deserialize_method, #read, #serialize_for, #serialize_method, #serialize_node

Methods included from Binding::Object

#create_object, #deserialize, #serialize

Methods inherited from Binding

build, #compile_fragment, #get, #initialize, #read_fragment, #read_fragment_for, #set, #uncompile_fragment, #write_fragment, #write_fragment_for

Methods included from Binding::Prepare

#representer_module_for

Constructor Details

This class inherits a constructor from Representable::Binding

Instance Method Details

#deserialize_from(node) ⇒ Object



133
134
135
136
137
138
139
# File 'lib/representable/bindings/xml_bindings.rb', line 133

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?



126
127
128
129
130
131
# File 'lib/representable/bindings/xml_bindings.rb', line 126

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