Class: Dionysus::Consumer::Deserializer::SerializedRecord
- Inherits:
-
Object
- Object
- Dionysus::Consumer::Deserializer::SerializedRecord
- Defined in:
- lib/dionysus/consumer/deserializer.rb
Instance Method Summary collapse
- #canceled_at ⇒ Object
- #created_at ⇒ Object
- #expected_has_many_relationships ⇒ Object
- #expected_has_one_relationships ⇒ Object
- #has?(key) ⇒ Boolean
- #has_canceled_at? ⇒ Boolean
- #has_created_at? ⇒ Boolean
- #has_updated_at? ⇒ Boolean
- #id ⇒ Object
-
#initialize(payload) ⇒ SerializedRecord
constructor
A new instance of SerializedRecord.
- #links ⇒ Object
- #model_name_for_relationship(relationship_name) ⇒ Object
- #plain_attributes ⇒ Object
- #updated_at ⇒ Object
Constructor Details
#initialize(payload) ⇒ SerializedRecord
Returns a new instance of SerializedRecord.
157 158 159 |
# File 'lib/dionysus/consumer/deserializer.rb', line 157 def initialize(payload) @payload = payload end |
Instance Method Details
#canceled_at ⇒ Object
193 194 195 |
# File 'lib/dionysus/consumer/deserializer.rb', line 193 def canceled_at payload["canceled_at"] end |
#created_at ⇒ Object
185 186 187 |
# File 'lib/dionysus/consumer/deserializer.rb', line 185 def created_at payload["created_at"] end |
#expected_has_many_relationships ⇒ Object
165 166 167 |
# File 'lib/dionysus/consumer/deserializer.rb', line 165 def expected_has_many_relationships to_many_foreign_keys.keys end |
#expected_has_one_relationships ⇒ Object
169 170 171 |
# File 'lib/dionysus/consumer/deserializer.rb', line 169 def expected_has_one_relationships to_one_foreign_keys.keys end |
#has?(key) ⇒ Boolean
197 198 199 |
# File 'lib/dionysus/consumer/deserializer.rb', line 197 def has?(key) key?(key) end |
#has_canceled_at? ⇒ Boolean
209 210 211 |
# File 'lib/dionysus/consumer/deserializer.rb', line 209 def has_canceled_at? has?("canceled_at") end |
#has_created_at? ⇒ Boolean
201 202 203 |
# File 'lib/dionysus/consumer/deserializer.rb', line 201 def has_created_at? has?("created_at") end |
#has_updated_at? ⇒ Boolean
205 206 207 |
# File 'lib/dionysus/consumer/deserializer.rb', line 205 def has_updated_at? has?("updated_at") end |
#id ⇒ Object
181 182 183 |
# File 'lib/dionysus/consumer/deserializer.rb', line 181 def id payload["id"] end |
#links ⇒ Object
213 214 215 |
# File 'lib/dionysus/consumer/deserializer.rb', line 213 def links payload["links"].to_h end |
#model_name_for_relationship(relationship_name) ⇒ Object
173 174 175 176 177 178 179 |
# File 'lib/dionysus/consumer/deserializer.rb', line 173 def model_name_for_relationship(relationship_name) if polymorphic_relationship?(relationship_name) && links[relationship_name].key?("type") links[relationship_name]["type"] else relationship_name end end |
#plain_attributes ⇒ Object
161 162 163 |
# File 'lib/dionysus/consumer/deserializer.rb', line 161 def plain_attributes payload.except(*RESERVED_ATTRIBUTES, *expected_has_many_relationships, *expected_has_one_relationships) end |
#updated_at ⇒ Object
189 190 191 |
# File 'lib/dionysus/consumer/deserializer.rb', line 189 def updated_at payload["updated_at"] end |