Class: Timestamp

Inherits:
Object
  • Object
show all
Defined in:
lib/mongomapper_ext/types/timestamp.rb

Class Method Summary collapse

Class Method Details

.from_mongo(value) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/mongomapper_ext/types/timestamp.rb', line 2

def self.from_mongo(value)
  if value.nil? || value == ''
    nil
  else
    Time.zone.at(value.to_i)
  end
end

.to_mongo(value) ⇒ Object



10
11
12
# File 'lib/mongomapper_ext/types/timestamp.rb', line 10

def self.to_mongo(value)
  value.to_i
end