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



41
42
43
# File 'lib/erector/caching.rb', line 41

def cache
  self.class.cache
end

#cache_key_assignsObject



59
60
61
62
63
64
65
# File 'lib/erector/caching.rb', line 59

def cache_key_assigns
  if self.class.cache_opts[:only_keys]
    assigns.slice(*self.class.cache_opts[:only_keys])
  else
    assigns
  end
end

#caching_configured?Boolean

Returns:

  • (Boolean)


53
54
55
56
57
# File 'lib/erector/caching.rb', line 53

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)


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

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