Class: Dionysus::Consumer::Deserializer::DeserializedRecord
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Dionysus::Consumer::Deserializer::DeserializedRecord
- Defined in:
- lib/dionysus/consumer/deserializer.rb
Instance Method Summary collapse
- #attributes ⇒ Object
- #has_many ⇒ Object
- #has_one ⇒ Object
- #has_synced_canceled_at? ⇒ Boolean
-
#initialize ⇒ DeserializedRecord
constructor
A new instance of DeserializedRecord.
- #populate_attributes_with_relationship(relationship_name, value) ⇒ Object
- #synced_canceled_at ⇒ Object
- #synced_canceled_at=(val) ⇒ Object
- #synced_created_at ⇒ Object
- #synced_created_at=(val) ⇒ Object
- #synced_id ⇒ Object
- #synced_id=(val) ⇒ Object
- #synced_updated_at ⇒ Object
- #synced_updated_at=(val) ⇒ Object
- #transformed_payload ⇒ Object
Constructor Details
#initialize ⇒ DeserializedRecord
Returns a new instance of DeserializedRecord.
73 74 75 |
# File 'lib/dionysus/consumer/deserializer.rb', line 73 def initialize super(canonical_format) end |
Instance Method Details
#attributes ⇒ Object
81 82 83 |
# File 'lib/dionysus/consumer/deserializer.rb', line 81 def attributes transformed_payload.fetch(:attributes) end |
#has_many ⇒ Object
85 86 87 |
# File 'lib/dionysus/consumer/deserializer.rb', line 85 def has_many transformed_payload.fetch(:has_many) end |
#has_one ⇒ Object
89 90 91 |
# File 'lib/dionysus/consumer/deserializer.rb', line 89 def has_one transformed_payload.fetch(:has_one) end |
#has_synced_canceled_at? ⇒ Boolean
137 138 139 |
# File 'lib/dionysus/consumer/deserializer.rb', line 137 def has_synced_canceled_at? attributes.key?("synced_canceled_at") end |
#populate_attributes_with_relationship(relationship_name, value) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/dionysus/consumer/deserializer.rb', line 125 def populate_attributes_with_relationship(relationship_name, value) if value.respond_to?(:to_hash) attributes["synced_#{relationship_name}_id"] = value["id"] attributes["synced_#{relationship_name}_type"] = value["type"] elsif value.respond_to?(:to_ary) relationship_name = ActiveSupport::Inflector.singularize(relationship_name) attributes["synced_#{relationship_name}_ids"] = value else attributes["synced_#{relationship_name}_id"] = value end end |
#synced_canceled_at ⇒ Object
117 118 119 |
# File 'lib/dionysus/consumer/deserializer.rb', line 117 def synced_canceled_at attributes["synced_canceled_at"] end |
#synced_canceled_at=(val) ⇒ Object
121 122 123 |
# File 'lib/dionysus/consumer/deserializer.rb', line 121 def synced_canceled_at=(val) attributes["synced_canceled_at"] = val end |
#synced_created_at ⇒ Object
101 102 103 |
# File 'lib/dionysus/consumer/deserializer.rb', line 101 def synced_created_at attributes["synced_created_at"] end |
#synced_created_at=(val) ⇒ Object
105 106 107 |
# File 'lib/dionysus/consumer/deserializer.rb', line 105 def synced_created_at=(val) attributes["synced_created_at"] = val end |
#synced_id ⇒ Object
93 94 95 |
# File 'lib/dionysus/consumer/deserializer.rb', line 93 def synced_id attributes.fetch("synced_id") { "synced_id not found in #{attributes}! Something is very wrong." } end |
#synced_id=(val) ⇒ Object
97 98 99 |
# File 'lib/dionysus/consumer/deserializer.rb', line 97 def synced_id=(val) attributes["synced_id"] = val end |
#synced_updated_at ⇒ Object
109 110 111 |
# File 'lib/dionysus/consumer/deserializer.rb', line 109 def synced_updated_at attributes["synced_updated_at"] end |
#synced_updated_at=(val) ⇒ Object
113 114 115 |
# File 'lib/dionysus/consumer/deserializer.rb', line 113 def synced_updated_at=(val) attributes["synced_updated_at"] = val end |
#transformed_payload ⇒ Object
77 78 79 |
# File 'lib/dionysus/consumer/deserializer.rb', line 77 def transformed_payload __getobj__ end |