Module: Representable::Binding::Object

Includes:
Extend
Included in:
JSON::ObjectBinding, XML::ObjectBinding
Defined in:
lib/representable/binding.rb

Instance Method Summary collapse

Methods included from Extend

#extend_for

Instance Method Details

#create_objectObject



62
63
64
# File 'lib/representable/binding.rb', line 62

def create_object
  definition.sought_type.new
end

#deserialize(data) ⇒ Object



57
58
59
60
# File 'lib/representable/binding.rb', line 57

def deserialize(data) 
  # DISCUSS: does it make sense to skip deserialization of nil-values here?
  super(create_object).send(deserialize_method, data)
end

#serialize(object) ⇒ Object



51
52
53
54
55
# File 'lib/representable/binding.rb', line 51

def serialize(object)
  return object if object.nil?
  
  super(object).send(serialize_method, :wrap => false)
end