Class: Nylas::DeltaType

Inherits:
Types::ModelType show all
Defined in:
lib/nylas/delta.rb

Overview

Casts Delta data from either a webhook or a delta stream to a Delta

Instance Attribute Summary

Attributes inherited from Types::ModelType

#model

Instance Method Summary collapse

Methods inherited from Types::ModelType

#actual_attributes, #already_cast?, #json_key_from_attribute_name, #serialize, #serialize_for_api

Methods inherited from Types::ValueType

#deseralize, #serialize, #serialize_for_api

Constructor Details

#initializeDeltaType

Returns a new instance of DeltaType.



39
40
41
# File 'lib/nylas/delta.rb', line 39

def initialize
  super(model: Delta)
end

Instance Method Details

#cast(data) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/nylas/delta.rb', line 43

def cast(data)
  data = if data.key?(:object_data)
           object_data = data.delete(:object_data)
           data.merge(object_data)
         else
           data
         end

  data = data.merge(data[:attributes]) if data[:attributes]
  data[:object_attributes] = data.delete(:attributes)
  super(**data)
end