模块:Mongoid::Timestamps::Updated
- 扩展方式:
- ActiveSupport::Concern
- 包含在:
- Mongoid::Timestamps
- 定义于:
- lib/mongoid/timestamps/updated.rb ,
lib/mongoid/timestamps/updated/short.rb
Overview
此模块处理设置按时间戳更新文档的行为。
在命名空间下定义
模块: 短
实例方法摘要折叠
-
#able_to_set_updated_at? ⇒ true | false
能否设置更新后的时间戳?
-
# set_updated_at ⇒ 对象
将文档上的 updated_at 字段更新为当前时间。
实例方法详细信息
#able_to_set_updated_at? ⇒ true | false
是否可以设置更新后的时间戳?
37 38 39 |
# File 'lib/mongoid/timestamps/updated.rb', line 37 def able_to_set_updated_at? !冻结? && !永恒? && (new_record? || 改变?) end |
# set_updated_at ⇒对象
将文档上的 updated_at 字段更新为当前时间。 这只在创建和保存时调用。
25 26 27 28 29 |
# File 'lib/mongoid/timestamps/updated.rb', line 25 def set_updated_at self.updated_at = 时间.Current if able_to_set_updated_at? && !updated_at_changed? clear_timeless_option end |