模块:Mongoid::Extensions::DateTime

定义于:
lib/mongoid/extensions/date_time.rb

Overview

为 Time 类添加类型转换行为。

在命名空间下定义

模块: 类方法

实例方法摘要折叠

实例方法详细信息

# __mongoize_time__时间| ActiveSupport::TimeWithZone

将日期时间 Mongoize 为时间。

例子:

将日期时间 Mongoize。

date_time.__mongoize_time__

返回:

  • ( Time | ActiveSupport::TimeWithZone )

    mongosized 时间。



16
17
18
# File 'lib/mongoid/extensions/date_time.rb', line 16

def __mongoize_time__
  in_time_zone(::时间.区域)
end

# mongoize时间

将对象从我们处理的Ruby类型转换为mongo友好类型。

例子:

将对象 Mongoize。

date_time.mongoize

返回:

  • 时间

    该对象已mongo化。



27
28
29
# File 'lib/mongoid/extensions/date_time.rb', line 27

def mongoize
  ::日期时间.mongoize(self)
end