模块: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 数组。
15 16 17 18 |
# File 'lib/mongoid/extensions/ 大量.rb', line 15 def __evolve_object_id__ 地图!(和:__evolve_object_id__) self end |
# __find_args__ ⇒数组
已弃用。
获取 args 数组作为查找查询的参数。
27 28 29 |
# File 'lib/mongoid/extensions/ 大量.rb', line 27 def __find_args__ flat_map{ |a| a.__find_args__ }.uniq{ |a| a.to_s } end |
# __mongoize_object_id__ "> Array <BSON::ObjectId>
将数组 Mongoize 为对象 ID 数组。
38 39 40 41 |
# File 'lib/mongoid/extensions/ 大量.rb', line 38 def __mongoize_object_id__ 地图!(和:__mongoize_object_id__).紧凑! self end |
# __mongoize_time__ ⇒时间| ActiveSupport::TimeWithZone
注意:
返回默认时区的本地时间。
将数组转换为时间进行存储。
54 55 56 |
# File 'lib/mongoid/extensions/ 大量.rb', line 54 def __mongoize_time__ ::时间.区域.local(*self) end |
# delete_one (object) ⇒对象
删除数组中与所提供对象相等的第一个对象并将其返回。 这比对大型数组执行标准删除要快得多,因为它不执行多次删除。
91 92 93 94 |
# File 'lib/mongoid/extensions/ 大量.rb', line 91 def delete_one(对象) Position = 索引(index)(对象) Position ? delete_at(Position) : nil end |
# mongoize ⇒数组| nil
将对象从我们处理的Ruby类型转换为mongo友好类型。
77 78 79 |
# File 'lib/mongoid/extensions/ 大量.rb', line 77 def mongoize ::阵列.mongoize(self) end |
# multi_arged? ⇒ true | false
已弃用。
数组是方法中包含多个参数的集合吗?
65 66 67 |
# File 'lib/mongoid/extensions/ 大量.rb', line 65 def multi_arged? !first.is_a?(哈希) && first.可调整大小? || size > 1 end |
#可调整大小? ⇒ true
返回对象大小是否可以更改的信息。
102 103 104 |
# File 'lib/mongoid/extensions/ 大量.rb', line 102 def 可调整大小? true end |