module Mongoid::Extensions::DateTime::ClassMethods

Public Instance Methods

demongoize(object) click to toggle source

Convert the object from its mongo friendly ruby type to this type.

@example Demongoize the object.

DateTime.demongoize(object)

@param [ Time ] object The time from Mongo.

@return [ DateTime ] The object as a date.

@since 3.0.0

# File lib/mongoid/extensions/date_time.rb, line 50
def demongoize(object)
  ::Time.demongoize(object).try(:to_datetime)
end
mongoize(object) click to toggle source

Turn the object from the ruby type we deal with to a Mongo friendly type.

@example Mongoize the object.

DateTime.mongoize("2012-1-1")

@param [ Object ] object The object to convert.

@return [ Time ] The object mongoized.

@since 3.0.0

# File lib/mongoid/extensions/date_time.rb, line 65
def mongoize(object)
  ::Time.mongoize(object)
end