Module: TaggableCache::ActionControllerExtension

Defined in:
lib/taggable_cache/extensions/action_controller.rb

Instance Method Summary collapse

Instance Method Details

#depends_on(*keys) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/taggable_cache/extensions/action_controller.rb', line 3

def depends_on(*keys)
  _process_action_callbacks.find_all{|x| 
      (x.kind == :around) && 
      (x.raw_filter.is_a? ActionController::Caching::Actions::ActionCacheFilter) }.each do |callback|
    cache_path = callback.raw_filter.instance_variable_get('@cache_path')

    path_options = if cache_path.respond_to?(:call)
      instance_exec(self, &cache_path)
    else
      cache_path
    end

    path_options = ::ActionController::Caching::Actions::ActionCachePath.new(self, path_options || {}).path

    Rails.cache.add_tags(fragment_cache_key(path_options), *keys)
  end
end