Sha256: cdb61699d47346ae601b03d788f1a5ef5bb5950a94d0675be553bb765befa99e

Contents?: true

Size: 421 Bytes

Versions: 3

Compression:

Stored size: 421 Bytes

Contents

# frozen_string_literal: true

module AdequateSerialization
  module Rails
    module CacheKey
      def self.cacheable?(object)
        if object.class < ActiveRecord::Base
          object.has_attribute?(:updated_at)
        else
          object.respond_to?(:cache_key)
        end
      end

      def self.for(object, includes = [])
        includes.empty? ? object : [object, *includes]
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
adequate_serialization-0.1.1 lib/adequate_serialization/rails/cache_key.rb
adequate_serialization-0.1.0 lib/adequate_serialization/rails/cache_key.rb
adequate_serialization-0.0.1 lib/adequate_serialization/rails/cache_key.rb