模块: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
是否可以设置更新后的时间戳?
40 41 42 |
# File 'lib/mongoid/timestamps/updated.rb', line 40 def able_to_set_updated_at? !冻结? && !永恒? && (new_record? || 改变?) end |
# set_updated_at ⇒对象
将文档上的 updated_at 字段更新为当前时间。 这只在创建和保存时调用。
26 27 28 29 30 31 32 |
# File 'lib/mongoid/timestamps/updated.rb', line 26 def set_updated_at if able_to_set_updated_at? self.updated_at = 时间.Current 除非 updated_at_changed? end clear_timeless_option end |