Module: Mongoid::Extensions::DateTime

Defined in:
build/mongoid-master/lib/mongoid/extensions/date_time.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#__mongoize_time__Time | ActiveSupport::TimeWithZone

Mongoize the date time into a time.

Examples:

Mongoize the date time.

date_time.__mongoize_time__

Returns:

  • (Time | ActiveSupport::TimeWithZone)

    The mongoized time.

Since:

  • 3.0.0



16
17
18
19
20
21
22
23
# File 'build/mongoid-master/lib/mongoid/extensions/date_time.rb', line 16

def __mongoize_time__
  if Mongoid.use_activesupport_time_zone?
    in_time_zone(::Time.zone)
  else
    time = to_time
    time.respond_to?(:getlocal) ? time.getlocal : time
  end
end

#mongoizeTime

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

Examples:

Mongoize the object.

date_time.mongoize

Returns:

  • (Time)

    The object mongoized.

Since:

  • 3.0.0



34
35
36
# File 'build/mongoid-master/lib/mongoid/extensions/date_time.rb', line 34

def mongoize
  ::DateTime.mongoize(self)
end