Class: Date

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

Class Method Summary collapse

Class Method Details

.from_mongo(value) ⇒ Object



50
51
52
# File 'lib/mongo_mapper/support.rb', line 50

def self.from_mongo(value)
  value.to_date if value.present?
end

.to_mongo(value) ⇒ Object



43
44
45
46
47
48
# File 'lib/mongo_mapper/support.rb', line 43

def self.to_mongo(value)
  date = Date.parse(value.to_s)
  Time.utc(date.year, date.month, date.day)
rescue
  nil
end