123456789_123456789_123456789_123456789_123456789_

Module: Mongoid::Extensions::Date

Relationships & Source Files
Namespace Children
Modules:
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: lib/mongoid/extensions/date.rb

Overview

Adds type-casting behavior to Date class.

Instance Method Summary

Instance Method Details

#__mongoize_time__Time | ActiveSupport::TimeWithZone

Convert the date into a time.

Examples:

Convert the date to a time.

Date.new(2018, 11, 1).__mongoize_time__
# => Thu, 01 Nov 2018 00:00:00 EDT -04:00

Returns:

[ GitHub ]

  
# File 'lib/mongoid/extensions/date.rb', line 19

def __mongoize_time__
  ::Time.zone.local(year, month, day)
end

#mongoizeTime

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

Examples:

Mongoize the object.

date.mongoize

Returns:

  • (Time)

    The object mongoized.

[ GitHub ]

  
# File 'lib/mongoid/extensions/date.rb', line 30

def mongoize
  ::Date.mongoize(self)
end