Class: Nylas::Types::BooleanType

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

Overview

Type for attributes represented as booleans.

Instance Method Summary collapse

Methods inherited from ValueType

#deseralize, #serialize, #serialize_for_api

Instance Method Details

#cast(value) ⇒ Object

Parameters:

  • value (Object)

    Strictly casts the passed in value to a boolean (must be true, not “” or 1)

Raises:

  • (TypeError)


147
148
149
150
151
152
153
# File 'lib/nylas/types.rb', line 147

def cast(value)
  return nil if value.nil?
  return true if value == true
  return false if value == false

  raise TypeError, "#{value} must be either true or false"
end