Module: Components::Caching::ClassMethods

Defined in:
lib/components/caching.rb

Instance Method Summary collapse

Instance Method Details

#cache(action, cache_options = nil) ⇒ Object

Caches the named actions by wrapping them via alias_method_chain. May only be called on actions (methods) that have already been defined.

Cache options will be passed through to the cache store’s read/write methods.



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/components/caching.rb', line 93

def cache(action, cache_options = nil)
  return unless ActionController::Base.cache_configured?

  class_eval "    cattr_accessor :\#{action}_cache_options\n\n    def \#{action}_with_caching(*args)\n      with_caching(:\#{action}, args) do\n        \#{action}_without_caching(*args)\n      end\n    end\n    alias_method_chain :\#{action}, :caching\n  EOL\n  self.send(\"\#{action}_cache_options=\", cache_options)\nend\n", __FILE__, __LINE__

#cache_storeObject

:nodoc:



109
110
111
# File 'lib/components/caching.rb', line 109

def cache_store #:nodoc:
  @cache_store ||= ActionController::Base.cache_store
end