Class: Nylas::Types::HashType

Inherits:
ValueType show all
Defined in:
lib/nylas/types.rb

Overview

Casts/Serializes data that is persisted and used natively as a Hash

Instance Method Summary collapse

Methods inherited from ValueType

#deseralize, #serialize_for_api

Instance Method Details

#cast(value) ⇒ Object



35
36
37
38
# File 'lib/nylas/types.rb', line 35

def cast(value)
  return JSON.parse(value, symbolize_names: true) if value.is_a?(String)
  return value if value.respond_to?(:key)
end

#serialize(object) ⇒ Object



31
32
33
# File 'lib/nylas/types.rb', line 31

def serialize(object)
  object.to_h
end