Class: Boolean
Constant Summary collapse
- BOOLEAN_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 => false }
Class Method Summary collapse
Class Method Details
.from_mongo(value) ⇒ Object
42 43 44 |
# File 'lib/mongo_mapper/support.rb', line 42 def self.from_mongo(value) !!value end |
.to_mongo(value) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/mongo_mapper/support.rb', line 32 def self.to_mongo(value) if value.is_a?(Boolean) value else v = BOOLEAN_MAPPING[value] v = value.to_s.downcase == 'true' if v.nil? # Check all mixed case spellings for true v end end |