Sha256: 9221c6597ac7653f788369007a48b5176a8b81f8dbdd2f501178a501bb6e0275
Contents?: true
Size: 974 Bytes
Versions: 10
Compression:
Stored size: 974 Bytes
Contents
module Fish0 module Concerns module Cacheable extend ActiveSupport::Concern included do def cache_key(*timestamp_names) case when timestamp_names.any? timestamp = max_updated_column_timestamp(timestamp_names) "#{self.class.to_s.tableize}/#{primary_key_value}-#{timestamp.utc.to_s(:nsec)}" when timestamp = max_updated_column_timestamp "#{self.class.to_s.tableize}/#{primary_key_value}-#{timestamp.utc.to_s(:nsec)}" else "#{self.class.to_s.tableize}/#{primary_key_value}" end end private def timestamp_attributes_for_update [:updated_at] end def max_updated_column_timestamp(timestamp_names = timestamp_attributes_for_update) timestamp_names .map { |attr| self[attr] } .compact .map(&:to_time) .max end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems