123456789_123456789_123456789_123456789_123456789_

Module: Mongoid::Extensions::DateTime::ClassMethods

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Extended In:
Defined in: lib/mongoid/extensions/date_time.rb

Instance Method Summary

Instance Method Details

#demongoize(object) ⇒ DateTime | nil

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

Examples:

Demongoize the object.

DateTime.demongoize(object)

Parameters:

  • object (Time)

    The time from Mongo.

Returns:

  • (DateTime | nil)

    The object as a datetime or nil.

[ GitHub ]

  
# File 'lib/mongoid/extensions/date_time.rb', line 41

def demongoize(object)
  ::Time.demongoize(object).try(:to_datetime)
end

#mongoize(object) ⇒ Time

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

Examples:

Mongoize the object.

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

Parameters:

  • object (Object)

    The object to convert.

Returns:

  • (Time)

    The object mongoized.

[ GitHub ]

  
# File 'lib/mongoid/extensions/date_time.rb', line 54

def mongoize(object)
  ::Time.mongoize(object)
end