Module: CachedAt
- Defined in:
- lib/cached_at.rb,
lib/cached_at/version.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- VERSION =
"0.0.2"
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/cached_at.rb', line 4 def self.included(klass) klass.instance_eval do before_save :_set_cached_at klass.extend ClassMethods end end |
Instance Method Details
#cache_key ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/cached_at.rb', line 11 def cache_key case when new_record? "#{self.class.model_name.cache_key}/new" when = self[:cached_at] = .utc.to_s(:number) "#{self.class.model_name.cache_key}/#{id}-#{}" else "#{self.class.model_name.cache_key}/#{id}" end end |
#touch(name = nil) ⇒ Object
23 24 25 |
# File 'lib/cached_at.rb', line 23 def touch(name = nil) update_column :cached_at, current_time_from_proper_timezone end |