Module: Erector::Caching

Included in:
Widget
Defined in:
lib/erector/caching.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
# File 'lib/erector/caching.rb', line 3

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#cacheObject



35
36
37
# File 'lib/erector/caching.rb', line 35

def cache
  self.class.cache
end

#caching_configured?Boolean

Returns:

  • (Boolean)


47
48
49
50
51
# File 'lib/erector/caching.rb', line 47

def caching_configured?
  return true if !defined?(Rails)
  ::Rails.configuration.action_controller.perform_caching &&
  ::Rails.configuration.action_controller.cache_store
end

#should_cache?Boolean

Returns:

  • (Boolean)


39
40
41
42
43
44
45
# File 'lib/erector/caching.rb', line 39

def should_cache?
  if block.nil? && self.class.cachable? && caching_configured?
    true
  else
    false
  end
end