类:Mongoid::AtomicUpdatePreparer Private
- 继承:
-
对象
- 对象
- Mongoid::AtomicUpdatePreparer
- 定义于:
- lib/mongoid/atomic_update_preparer.rb
Overview
此类是私有 API 的一部分。 应尽可能避免使用此类,因为它将来可能会被删除或更改。
一个单例类,用于协助为原子更新准备属性。
一旦已弃用的 Hash#__consolidate__ 方法被完全删除,这些方法就可以作为私有方法转移到 Mongoid::Contextual::Mongo 中。
类方法摘要折叠
-
。 prepare (attributes, klass) ⇒ 哈希
private
将属性中的键/值转换为原子更新的哈希值。
类方法详细信息
。 prepare (attributes, klass) ⇒哈希
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
将属性中的键/值转换为原子更新的哈希值。 假定非操作符键使用 $ 设立操作。
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mongoid/atomic_update_preparer.rb', line 21 def 准备(属性, klass) 属性.each_pair.with_object({}) do |(key, 值), atomic_updates| key = klass.database_field_name(key.to_s) if key.to_s.start_with?('$') (atomic_updates[key] ||= {}).update(prepare_operation(klass, key, 值)) else (atomic_updates[' $set '] ||= {})[key] = mongoize_for(' $set ', klass, key, 值) end end end |