Sha256: cecbebe12f4259a87dc2addf2652403bdcfa8f4ae5f82b7d95fe324abf2e079f

Contents?: true

Size: 668 Bytes

Versions: 5

Compression:

Stored size: 668 Bytes

Contents

# encoding: UTF-8
module MongoMapper
  module Plugins
    module Caching
      extend ActiveSupport::Concern

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mongo_mapper-0.10.1 lib/mongo_mapper/plugins/caching.rb
mongo_mapper-0.10.0 lib/mongo_mapper/plugins/caching.rb
mongo_mapper-0.9.2 lib/mongo_mapper/plugins/caching.rb
mongo_mapper-0.9.1 lib/mongo_mapper/plugins/caching.rb
mongo_mapper-0.9.0 lib/mongo_mapper/plugins/caching.rb