module Erector::Caching
Public Class Methods
included(base)
click to toggle source
# File lib/erector/caching.rb, line 3 def self.included(base) base.extend ClassMethods end
Public Instance Methods
cache_name()
click to toggle source
# File lib/erector/caching.rb, line 31 def cache_name [].tap do |a| self.class.cacheable_opts[:static_keys].each do |x| if x.is_a?(Symbol) && respond_to?(x) a << send(x) else a << x end end self.class.cacheable_opts[:dynamic_keys].each do |x| a << instance_variable_get(:"@#{x}") end end.reject(&:nil?) end
cache_options()
click to toggle source
# File lib/erector/caching.rb, line 47 def cache_options { skip_digest: self.class.cacheable_opts[:skip_digest] } end
cacheable?()
click to toggle source
# File lib/erector/caching.rb, line 27 def cacheable? !self.class.cacheable_opts.nil? end
Protected Instance Methods
_emit(options = {})
click to toggle source
Calls superclass method
# File lib/erector/caching.rb, line 54 def _emit(options = {}) if cacheable? && options[:helpers].try(:respond_to?, :cache) options[:helpers].cache cache_name, cache_options do super end else super end end