Class: Representable::JSON::ObjectBinding

Inherits:
Binding
  • Object
show all
Defined in:
lib/representable/bindings/json_bindings.rb

Overview

Represents a tag with object binding.

Instance Attribute Summary

Attributes inherited from Binding

#definition

Instance Method Summary collapse

Methods inherited from Binding

#initialize, #read

Constructor Details

This class inherits a constructor from Representable::JSON::Binding

Instance Method Details

#write(hash, value) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/representable/bindings/json_bindings.rb', line 45

def write(hash, value)
  if definition.array?
    hash.merge!({definition.from => value.collect {|v| v.to_hash(:wrap => false)}})
  else
    hash.merge! value.to_hash
  end
end