Class: Representable::ObjectDeserializer

Inherits:
Object
  • Object
show all
Defined in:
lib/representable/deserializer.rb

Direct Known Subclasses

ObjectSerializer

Instance Method Summary collapse

Constructor Details

#initialize(binding) ⇒ ObjectDeserializer

dependencies: Def#options, Def#create_object



20
21
22
# File 'lib/representable/deserializer.rb', line 20

def initialize(binding)
  @binding = binding
end

Instance Method Details

#call(fragment, *args) ⇒ Object

FIXME: args is always i.



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/representable/deserializer.rb', line 24

def call(fragment, *args) # FIXME: args is always i.
  return fragment unless @binding.typed? # customize with :extend. this is not really straight-forward.

  # what if create_object is responsible for providing the deserialize-to object?
  object = @binding.create_object(fragment, *args) # customize with :instance and :class.

  # DISCUSS: what parts should be in this class, what in Binding?
  representable = prepare(object) # customize with :prepare and :extend.

  deserialize(representable, fragment, @binding.user_options) # deactivate-able via :representable => false.
end