Module: Mongo::Model::BooleanType

Included in:
Boolean
Defined in:
lib/mongo_db/model/support/types.rb

Overview

Boolean

Constant Summary collapse

Mapping =
{
  true    => true,
  'true'  => true,
  'TRUE'  => true,
  'True'  => true,
  't'     => true,
  'T'     => true,
  '1'     => true,
  1       => true,
  1.0     => true,
  false   => false,
  'false' => false,
  'FALSE' => false,
  'False' => false,
  'f'     => false,
  'F'     => false,
  '0'     => false,
  0       => false,
  0.0     => false,
  nil     => nil
}

Instance Method Summary collapse

Instance Method Details

#cast(value) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/mongo_db/model/support/types.rb', line 27

def cast value
  if value.is_a? Boolean
    value
  else
    Mapping[value] || false
  end
end