Sha256: 4ad67c9692ed847583c0eaf6fae0fae621cd4e3d8ed423d1ae2c4a0a52f56660

Contents?: true

Size: 589 Bytes

Versions: 13

Compression:

Stored size: 589 Bytes

Contents

module Toy
  module Caching
    extend ActiveSupport::Concern

    module InstanceMethods
      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
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
toystore-0.8.3 lib/toy/caching.rb
toystore-0.8.2 lib/toy/caching.rb
toystore-0.8.1 lib/toy/caching.rb
toystore-0.8.0 lib/toy/caching.rb
toystore-0.7.0 lib/toy/caching.rb
toystore-0.6.6 lib/toy/caching.rb
toystore-0.6.5 lib/toy/caching.rb
toystore-0.6.4 lib/toy/caching.rb
toystore-0.6.3 lib/toy/caching.rb
toystore-0.6.2 lib/toy/caching.rb
toystore-0.6.1 lib/toy/caching.rb
toystore-0.6 lib/toy/caching.rb
toystore-0.5 lib/toy/caching.rb