Sha256: 5871ba6f9f78763753c5a3a34f51307fbd89eb1f9e36c56b3519f8c78fdc41cb

Contents?: true

Size: 471 Bytes

Versions: 3

Compression:

Stored size: 471 Bytes

Contents

# frozen_string_literal: true

module AdequateSerialization
  module Rails
    class CacheStep < Steps::PassthroughStep
      def apply(response)
        object = response.object
        opts = response.opts

        if opts.options[:multi_caching] || !CacheKey.cacheable?(object)
          return apply_next(response)
        end

        ::Rails.cache.fetch(CacheKey.for(object, opts.includes)) do
          apply_next(response)
        end
      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_step.rb
adequate_serialization-0.1.0 lib/adequate_serialization/rails/cache_step.rb
adequate_serialization-0.0.1 lib/adequate_serialization/rails/cache_step.rb