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