Class: Intercom::Lib::TypedJsonDeserializer
- Inherits:
-
Object
- Object
- Intercom::Lib::TypedJsonDeserializer
- Defined in:
- lib/intercom/lib/typed_json_deserializer.rb
Overview
Responsibility: To decide whether we are deserializing a collection or an entity of a particular type and to dispatch deserialization
Instance Attribute Summary collapse
-
#json ⇒ Object
readonly
Returns the value of attribute json.
Instance Method Summary collapse
- #deserialize ⇒ Object
-
#initialize(json) ⇒ TypedJsonDeserializer
constructor
A new instance of TypedJsonDeserializer.
Constructor Details
#initialize(json) ⇒ TypedJsonDeserializer
Returns a new instance of TypedJsonDeserializer.
9 10 11 |
# File 'lib/intercom/lib/typed_json_deserializer.rb', line 9 def initialize(json) @json = json end |
Instance Attribute Details
#json ⇒ Object (readonly)
Returns the value of attribute json.
7 8 9 |
# File 'lib/intercom/lib/typed_json_deserializer.rb', line 7 def json @json end |
Instance Method Details
#deserialize ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/intercom/lib/typed_json_deserializer.rb', line 13 def deserialize if blank_object_type?(object_type) raise DeserializationError, "No type field was found to facilitate deserialization" elsif list_object_type?(object_type) deserialize_collection(json[object_entity_key]) else # singular object type deserialize_object(json) end end |