Module: MongoMapper::Extensions::Boolean

Defined in:
lib/mongo_mapper/extensions/boolean.rb

Constant Summary

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

- (Object) from_mongo(value)



31
32
33
34
# File 'lib/mongo_mapper/extensions/boolean.rb', line 31

def from_mongo(value)
  return nil if value == nil
  !!value
end

- (Object) to_mongo(value)



27
28
29
# File 'lib/mongo_mapper/extensions/boolean.rb', line 27

def to_mongo(value)
  Mapping[value]
end