Class: Nylas::Types::DateType

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

Overview

Type for attributes represented as an iso8601 dates in the API and Date in Ruby

Instance Method Summary collapse

Methods inherited from ValueType

#deseralize, #serialize_for_api

Instance Method Details

#cast(value) ⇒ Object



108
109
110
111
112
# File 'lib/nylas/types.rb', line 108

def cast(value)
  return nil if value.nil?

  Date.parse(value)
end

#serialize(value) ⇒ Object



114
115
116
117
118
# File 'lib/nylas/types.rb', line 114

def serialize(value)
  return value.iso8601 if value.respond_to?(:iso8601)

  value
end