模块:Mongoid::Touchable
Overview
Mongoid::Document 中包含的 Mixin 模块,用于添加“触摸”功能,从而自动更新文档的时间戳。
在命名空间下定义
模块: InstanceMethods
实例方法摘要折叠
-
#define_touchable! (关联)⇒ 类
如果提供了 touch 选项,则将关联添加到可触摸关联中。
-
# suggest_touch_callbacks (name) ⇒ 对象
private
在关联区块的持续时间内,抑制命名类的触摸回调。
-
# touch_callbacks_suppressed? (name) ⇒ true | false
private
查询指定类的触摸回调是否被抑制。
实例方法详细信息
#define_touchable! (关联)⇒类
如果提供了 touch 选项,则将关联添加到可触摸关联中。
153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/mongoid/touchable.rb', line 153 def 定义_可触摸!(关联) 名称 = 关联.名称 method_name = define_relation_touch_method(名称, 关联) 关联.inverse_class.点击 do |klass| klass.after_save method_name klass.after_destroy method_name # 嵌入式Docs递归处理触摸更新 # #touch 方法本身 klass.after_touch method_name 除非 关联. end end |
# suggest_touch_callbacks (name) ⇒对象
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
在关联区块的持续时间内,抑制命名类的触摸回调。
170 171 172 173 174 175 |
# File 'lib/mongoid/touchable.rb', line 170 def subsup_touch_callbacks(名称) 保存, touch_callback_statuses[名称] = touch_callback_statuses[名称], true 产量 确保 touch_callback_statuses[名称] = 保存 end |
# touch_callbacks_suppressed? (name) ⇒ true | false
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
查询指定类的触摸回调是否被抑制。
183 184 185 |
# File 'lib/mongoid/touchable.rb', line 183 def touch_callbacks_suppressed?(名称) touch_callback_statuses[名称] end |