Module: CacheDebugging::CacheBlocks

Extended by:
ActiveSupport::Concern
Defined in:
lib/cache_debugging/cache_blocks.rb

Instance Method Summary collapse

Instance Method Details

#cache_with_blocks(name = {}, options = nil, &block) ⇒ Object

every time we start a cache block, we want to store the template and the block’s dependencies



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cache_debugging/cache_blocks.rb', line 10

def cache_with_blocks(name = {}, options = nil, &block)
  if current_template
    dependencies = Digestor.new(
      current_template,
      lookup_context.rendered_format || :html, ApplicationController.new.lookup_context
    ).nested_dependencies

    cache_blocks.push({
      template: current_template,
      dependencies: Utils.deep_flatten(dependencies)
    })
    ret = cache_without_blocks(name, options, &block)
    cache_blocks.pop
    ret
  else
    cache_without_blocks(name, options, &block)
  end
end