模块:Mongoid::Extensions::Array
- 定义于:
- lib/mongoid/extensions/ 大量.rb
Overview
为 Array 类添加类型转换行为。
在命名空间下定义
模块: 类方法
实例方法摘要折叠
-
# __evolve_object_id__ ⇒ Array<BSON::ObjectId>
将数组演进为对象 ID 数组。
- #__find_args__ ⇒ Array 已弃用 已弃用。
-
# __mongoize_object_id__ ⇒ Array<BSON::ObjectId>
将数组 Mongoize 为对象 ID 数组。
-
# __mongoize_time__ ⇒ 时间 | ActiveSupport::TimeWithZone
将数组转换为时间进行存储。
-
# delete_one (object) ⇒ 对象
删除数组中与所提供对象相等的第一个对象并将其返回。
-
# mongoize ⇒ 数组 | nil
将对象从我们处理的Ruby类型转换为mongo友好类型。
- # multi_arged? ⇒ true | false 已弃用 已弃用。
-
#可调整大小? ⇒ true
返回对象大小是否可以更改的信息。
实例方法详细信息
# __evolve_object_id__ "> Array <BSON::ObjectId>
将数组演进为对象 ID 数组。
13 14 15 16 |
# File 'lib/mongoid/extensions/ 大量.rb', line 13 def __evolve_object_id__ 地图!(和:__evolve_object_id__) self end |
# __find_args__ ⇒数组
已弃用。
获取 args 数组作为查找查询的参数。
25 26 27 |
# File 'lib/mongoid/extensions/ 大量.rb', line 25 def __find_args__ flat_map { |a| a.__find_args__ }.uniq { |a| a.to_s } end |
# __mongoize_object_id__ "> Array <BSON::ObjectId>
将数组 Mongoize 为对象 ID 数组。
36 37 38 39 |
# File 'lib/mongoid/extensions/ 大量.rb', line 36 def __mongoize_object_id__ 地图!(和:__mongoize_object_id__).紧凑! self end |
# __mongoize_time__ ⇒时间| ActiveSupport::TimeWithZone
注意:
返回默认时区的本地时间。
将数组转换为时间进行存储。
52 53 54 |
# File 'lib/mongoid/extensions/ 大量.rb', line 52 def __mongoize_time__ ::时间.区域.local(*self) end |
# delete_one (object) ⇒对象
删除数组中与所提供对象相等的第一个对象并将其返回。 这比对大型数组执行标准删除要快得多,因为它不执行多次删除。
89 90 91 92 |
# File 'lib/mongoid/extensions/ 大量.rb', line 89 def delete_one(对象) Position = 索引(index)(对象) Position ? delete_at(Position) : nil end |
# mongoize ⇒数组| nil
将对象从我们处理的Ruby类型转换为mongo友好类型。
75 76 77 |
# File 'lib/mongoid/extensions/ 大量.rb', line 75 def mongoize ::阵列.mongoize(self) end |
# multi_arged? ⇒ true | false
已弃用。
数组是方法中包含多个参数的集合吗?
63 64 65 |
# File 'lib/mongoid/extensions/ 大量.rb', line 63 def multi_arged? (!first.is_a?(哈希) && first.可调整大小?) || size > 1 end |
#可调整大小? ⇒ true
返回对象大小是否可以更改的信息。
100 101 102 |
# File 'lib/mongoid/extensions/ 大量.rb', line 100 def 可调整大小? true end |