模块:Mongoid::Persistable::Minable
Overview
定义将一个或多个字段设置为当前值或给定值中较小值的行为。
实例方法摘要折叠
-
# set_min (fields) ⇒ 文档(也:#clamp_upper_bound)
将给定的一个或多个字段设置为当前值或给定值中较小的值。
实例方法详细信息
# set_min (fields) ⇒文档也称为: clip_upper_bound
将给定的一个或多个字段设置为当前值或给定值中较小的值。
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mongoid/persistable/minable.rb', line 22 def set_min(字段) prepare_atomic_operation do |运维| process_atomic_operations(字段) do |字段, 值| current_value = 属性[字段] if 值 < current_value process_attribute 字段, 值 运维[atomic_attribute_name(字段)] = 值 end end { "$min" => 运维 } 除非 运维.空? end end |