Class: Wukong::Processor::Recordize
- Inherits:
-
Serializer
- Object
- Hanuman::Stage
- Wukong::Processor
- Serializer
- Wukong::Processor::Recordize
- Defined in:
- lib/wukong/widget/serializers.rb
Overview
A widget for turning a record into an instance of some class.
The class must provide a "class method" receive which accepts
a Hash argument.
Constant Summary
Constants inherited from Wukong::Processor
Instance Method Summary collapse
-
#process(record) ⇒ Object
Turn the given
recordinto an instance of the class named with themodelfield.
Methods inherited from Serializer
Methods inherited from Wukong::Processor
configure, consumes, description, #expected_record_type, #expected_serialization, #finalize, #perform_action, produces, #receive_action, #setup, #stop, valid_serializer?, validate_and_set_serialization
Methods included from Logging
Methods included from Hanuman::StageClassMethods
#builder, #label, #register, #set_builder
Instance Method Details
#process(record) ⇒ Object
Turn the given record into an instance of the class named
with the model field.
292 293 294 295 296 297 298 |
# File 'lib/wukong/widget/serializers.rb', line 292 def process(record) wire_format = record.try(:to_wire) || record raise SerializerError.new("Can only recordize a Hash-like record") unless wire_format.is_a?(Hash) yield model.receive(wire_format) rescue => e handle_error(record, e) end |