Sha256: 94bdfaed2a80d4d694c55497a10cd8fb740cebe0b7c60dcaeaaab9b4f671c946

Contents?: true

Size: 530 Bytes

Versions: 11

Compression:

Stored size: 530 Bytes

Contents

module Toy
  module Caching
    extend ActiveSupport::Concern

    def cache_key(*suffixes)
      cache_key = case
                    when new_record?
                      "#{self.class.name}:new"
                    when timestamp = self[:updated_at]
                      "#{self.class.name}:#{id}-#{timestamp.utc.to_s(:number)}"
                    else
                      "#{self.class.name}:#{id}"
                  end
      cache_key += ":#{suffixes.join(':')}" unless suffixes.empty?
      cache_key
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
toystore-0.13.2 lib/toy/caching.rb
toystore-0.13.1 lib/toy/caching.rb
toystore-0.13.0 lib/toy/caching.rb
toystore-0.12.0 lib/toy/caching.rb
toystore-0.11.0 lib/toy/caching.rb
toystore-0.10.4 lib/toy/caching.rb
toystore-0.10.3 lib/toy/caching.rb
toystore-0.10.2 lib/toy/caching.rb
toystore-0.10.1 lib/toy/caching.rb
toystore-0.10.0 lib/toy/caching.rb
toystore-0.9.0 lib/toy/caching.rb