Class: Representable::Hash::HashBinding
- Inherits:
-
PropertyBinding
- Object
- SimpleDelegator
- Binding
- PropertyBinding
- Representable::Hash::HashBinding
- Defined in:
- lib/representable/bindings/hash_bindings.rb
Instance Attribute Summary
Attributes inherited from Binding
Instance Method Summary collapse
Methods inherited from PropertyBinding
build_for, #deserialize_from, #deserialize_method, #read, #serialize_method, #write
Methods included from Binding::Object
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
Constructor Details
This class inherits a constructor from Representable::Binding
Instance Method Details
#deserialize(fragment) ⇒ Object
58 59 60 61 62 |
# File 'lib/representable/bindings/hash_bindings.rb', line 58 def deserialize(fragment) {}.tap do |hsh| fragment.each { |key, item_fragment| hsh[key] = super(item_fragment) } end end |
#serialize(value) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/representable/bindings/hash_bindings.rb', line 51 def serialize(value) # requires value to respond to #each with two block parameters. {}.tap do |hsh| value.each { |key, obj| hsh[key] = super(obj) } end end |