Class: CustomFragmentCache::CacheHelperMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/custom_fragment_cache/cache_helper_method.rb

Class Method Summary collapse

Class Method Details

.base_custom_cache(context, method_name, resource, name, options = {}, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/custom_fragment_cache/cache_helper_method.rb', line 3

def self.base_custom_cache(context, method_name, resource, name, options = {}, &block)
  if CustomFragmentCache.configuration.enabled
    fragment_cache_key = ::CustomFragmentCache::Logic.cache_key(name, resource)
    default_options = { expires_in: CustomFragmentCache.configuration.expiration_time }
    context.__send__(method_name, fragment_cache_key, default_options.merge(options), &block)
  else
    block.call
  end
end