Class: Representable::Hash::CollectionBinding

Inherits:
PropertyBinding show all
Defined in:
lib/representable/bindings/hash_bindings.rb

Instance Attribute Summary

Attributes inherited from Binding

#lambda_context, #represented, #user_options

Instance Method Summary collapse

Methods inherited from PropertyBinding

build_for, #initialize, #read, #write

Methods inherited from Binding

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

Constructor Details

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

Instance Method Details

#deserialize_from(fragment) ⇒ Object



57
58
59
# File 'lib/representable/bindings/hash_bindings.rb', line 57

def deserialize_from(fragment)
  fragment.collect { |item_fragment| deserialize(item_fragment) }
end

#serialize_for(value) ⇒ Object



52
53
54
55
# File 'lib/representable/bindings/hash_bindings.rb', line 52

def serialize_for(value)
  # value.enum_for(:each_with_index).collect { |obj, i| serialize(obj, i) } # DISCUSS: provide ary index/hash key for representer_module_for?
  value.collect { |obj| serialize(obj) }
end