Module: Mongo::Model::BooleanType

Included in:
Boolean
Defined in:
lib/mongo/model/support/conversions.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



28
29
30
31
32
33
34
# File 'lib/mongo/model/support/conversions.rb', line 28

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