Class: Representable::Deserializer
- Inherits:
-
Object
- Object
- Representable::Deserializer
- Includes:
- Prepare
- Defined in:
- lib/representable/deserializer.rb
Overview
Deserializer’s job is deserializing the already parsed fragment into a scalar or an object. This object is then returned to the Populator.
It respects :deserialize, :prepare, :class, :instance
Collection bindings return an array of parsed fragment items (still native format, e.g. Nokogiri node, for nested objects).
Workflow
call -> instance/class -> prepare -> deserialize -> from_json.
Direct Known Subclasses
Defined Under Namespace
Modules: Prepare Classes: Collection, Hash
Instance Method Summary collapse
-
#call(fragment, *args) ⇒ Object
FIXME: args is always i.
-
#initialize(binding) ⇒ Deserializer
constructor
A new instance of Deserializer.
Methods included from Prepare
#prepare, #prepare!, #prepare_for
Constructor Details
#initialize(binding) ⇒ Deserializer
Returns a new instance of Deserializer.
12 13 14 |
# File 'lib/representable/deserializer.rb', line 12 def initialize(binding) @binding = binding end |
Instance Method Details
#call(fragment, *args) ⇒ Object
FIXME: args is always i.
16 17 18 19 20 21 22 23 24 |
# File 'lib/representable/deserializer.rb', line 16 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 = create_object(fragment, *args) # customize with :instance and :class. representable = prepare(object) # customize with :prepare and :extend. deserialize(representable, fragment, @binding.) # deactivate-able via :representable => false. end |