Class: Dionysus::Consumer::Deserializer
- Inherits:
-
Object
- Object
- Dionysus::Consumer::Deserializer
- Defined in:
- lib/dionysus/consumer/deserializer.rb
Defined Under Namespace
Classes: DeserializedRecord, SerializedRecord
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #deserialize ⇒ Object
-
#initialize(data) ⇒ Deserializer
constructor
A new instance of Deserializer.
Constructor Details
#initialize(data) ⇒ Deserializer
Returns a new instance of Deserializer.
8 9 10 |
# File 'lib/dionysus/consumer/deserializer.rb', line 8 def initialize(data) @data = data.to_a end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/dionysus/consumer/deserializer.rb', line 6 def data @data end |
Instance Method Details
#deserialize ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dionysus/consumer/deserializer.rb', line 12 def deserialize data.map { |serialized_payload| SerializedRecord.new(serialized_payload) }.map do |serialized_record| transformed_payload = DeserializedRecord.new transformed_payload = populate_attributes_with_relationships(serialized_record, transformed_payload) transformed_payload = assign_attributes(serialized_record, transformed_payload) serialized_record.expected_has_many_relationships.each do |relationship_name| deserialize_has_many_relationship(serialized_record, relationship_name, transformed_payload) end serialized_record.expected_has_one_relationships.each do |relationship_name| deserialize_has_one_relationship(serialized_record, relationship_name, transformed_payload) end transformed_payload end end |