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
#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
71 72 73 74 75 |
# File 'lib/representable/bindings/hash_bindings.rb', line 71 def deserialize_from(fragment) {}.tap do |hsh| fragment.each { |key, item_fragment| hsh[key] = deserialize(item_fragment) } end end |
#serialize_for(value) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/representable/bindings/hash_bindings.rb', line 64 def serialize_for(value) # requires value to respond to #each with two block parameters. {}.tap do |hsh| value.each { |key, obj| hsh[key] = serialize(obj) } end end |