Module: ActiveRecordTweaks::Integration::ClassMethods
- Defined in:
- lib/active_record_tweaks/integration.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#cache_key(*args) ⇒ Object
Returns a cache key for the ActiveRecord class based based on count and maximum value of update timestamp columns (e.g. Cookie based caching with expiration).
-
#cache_key_without_timestamp ⇒ Object
Returns a cache key for the ActiveRecord class based based on count only.
Class Method Details
.extended(_base) ⇒ Object
70 71 72 73 74 75 76 77 78 |
# File 'lib/active_record_tweaks/integration.rb', line 70 def self.extended(_base) # rubocop:disable all warn ([ "[DEPRECATION]", "`ActiveRecordTweaks::Integration::ClassMethods` is deprecated without replacement.", "Please read README in project for details." ].join(" ")) # rubocop:enable all end |
Instance Method Details
#cache_key(*args) ⇒ Object
Returns a cache key for the ActiveRecord class based based on count and maximum value of update timestamp columns (e.g. Cookie based caching with expiration)
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/active_record_tweaks/integration.rb', line 92 def cache_key(*args) = args.empty? ? [:updated_at] : args if ( = ()) = .utc.yield_self do |utc_time| if utc_time.respond_to?(:to_fs) utc_time.to_fs() else utc_time.to_s() end end "#{model_name.cache_key}/all/#{count}-#{}" else end end |
#cache_key_without_timestamp ⇒ Object
Returns a cache key for the ActiveRecord class based based on count only
Product.cache_key # => "products/all/0" (empty, has updated timestamp columns or not)
Product.cache_key # => "products/all/1" (not empty but has no updated timestamp columns)
Person.cache_key # => "people/all/1" (not empty and has updated timestamp columns)
117 118 119 |
# File 'lib/active_record_tweaks/integration.rb', line 117 def "#{model_name.cache_key}/all/#{count}" end |