Module: Representable::Binding::Object

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

Instance Method Summary collapse

Methods included from Extend

#extend_for

Instance Method Details

#create_objectObject



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

def create_object
  definition.sought_type.new
end

#deserialize(data) ⇒ Object



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

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



47
48
49
50
51
# File 'lib/representable/binding.rb', line 47

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