Class: AdequateSerialization::Rails::CacheStep

Inherits:
Steps::Step
  • Object
show all
Defined in:
lib/adequate_serialization/rails/cache_step.rb

Instance Attribute Summary

Attributes inherited from Steps::Step

#next_step

Instance Method Summary collapse

Methods inherited from Steps::Step

#initialize

Constructor Details

This class inherits a constructor from AdequateSerialization::Steps::Step

Instance Method Details

#apply(response) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/adequate_serialization/rails/cache_step.rb', line 20

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