module Mongoid::Extensions::DateTime

Adds type-casting behavior to Time class.

Public Instance Methods

__mongoize_time__() click to toggle source

Mongoize the date time into a time.

@example Mongoize the date time.

date_time.__mongoize_time__

@return [ Time | ActiveSupport::TimeWithZone ] The mongoized time.

# File lib/mongoid/extensions/date_time.rb, line 16
def __mongoize_time__
  in_time_zone(::Time.zone)
end
mongoize() click to toggle source

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

@example Mongoize the object.

date_time.mongoize

@return [ Time ] The object mongoized.

# File lib/mongoid/extensions/date_time.rb, line 27
def mongoize
  ::DateTime.mongoize(self)
end