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

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

Instance Method Summary collapse

Instance Method Details

#demongoize(object) ⇒ DateTime

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:

Since:

  • 3.0.0



50
51
52
# File 'build/mongoid-master/lib/mongoid/extensions/date_time.rb', line 50

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.

Since:

  • 3.0.0



65
66
67
# File 'build/mongoid-master/lib/mongoid/extensions/date_time.rb', line 65

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