Class: Icalia::Event::DeserializableResource

Inherits:
JSONAPI::Deserializable::Resource
  • Object
show all
Defined in:
lib/icalia-sdk-event-core/serialization/deserializable_resource.rb

Class Method Summary collapse

Class Method Details

.classify_data(data) ⇒ Object



20
21
22
# File 'lib/icalia-sdk-event-core/serialization/deserializable_resource.rb', line 20

def classify_data(data)
  classify_type data['type']
end

.classify_type(type) ⇒ Object



16
17
18
# File 'lib/icalia-sdk-event-core/serialization/deserializable_resource.rb', line 16

def classify_type(type)
  type.underscore.camelize
end

.get_stand_in(id:, type:) ⇒ Object



24
25
26
# File 'lib/icalia-sdk-event-core/serialization/deserializable_resource.rb', line 24

def get_stand_in(id:, type:)
  Icalia::ModelProxy.new id: id, type: type
end

.get_stand_ins(rel) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/icalia-sdk-event-core/serialization/deserializable_resource.rb', line 28

def get_stand_ins(rel)
  if rel['data'].nil?
    Icalia::Event::ModelCollectionProxy.new rel['links']
  else
    rel['data'].map do |data|
      get_stand_in id: data['id'], type: classify_data(data)
    end
  end
end