Class: Boolean

Inherits:
Object show all
Defined in:
lib/mongo_mapper/support.rb

Class Method Summary collapse

Class Method Details

.from_mongo(value) ⇒ Object



41
42
43
# File 'lib/mongo_mapper/support.rb', line 41

def self.from_mongo(value)
  !!value
end

.to_mongo(value) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/mongo_mapper/support.rb', line 33

def self.to_mongo(value)
  if value.is_a?(Boolean)
    value
  else
    ['true', 't', '1'].include?(value.to_s.downcase)
  end
end