Module: Mongoid::Extensions::TimeWithZone::ClassMethods

Defined in:
build/mongoid-8.1/lib/mongoid/extensions/time_with_zone.rb

Instance Method Summary collapse

Instance Method Details

#demongoize(object) ⇒ TimeWithZone

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

Examples:

Demongoize the object.

TimeWithZone.demongoize(object)

Parameters:

  • object (Time)

    The time from Mongo.

Returns:



51
52
53
# File 'build/mongoid-8.1/lib/mongoid/extensions/time_with_zone.rb', line 51

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

#mongoize(object) ⇒ Time

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

Examples:

Mongoize the object.

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

Parameters:

  • object (Object)

    The object to convert.

Returns:

  • (Time)

    The object mongoized.



64
65
66
# File 'build/mongoid-8.1/lib/mongoid/extensions/time_with_zone.rb', line 64

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