Class: Memorize::Action::MemorizeFilter
- Inherits:
-
Object
- Object
- Memorize::Action::MemorizeFilter
- Defined in:
- lib/memorize/action.rb
Overview
:nodoc:
Instance Method Summary collapse
- #after(cache_path, controller) ⇒ Object
- #before(cache_path, controller) ⇒ Object
- #filter(controller, action) ⇒ Object
-
#initialize(options) ⇒ MemorizeFilter
constructor
A new instance of MemorizeFilter.
Constructor Details
#initialize(options) ⇒ MemorizeFilter
Returns a new instance of MemorizeFilter.
26 27 28 29 30 31 |
# File 'lib/memorize/action.rb', line 26 def initialize() @cache_path = .delete(:cache_path) @key_builder = .delete(:key_builder) @key_param = .delete(:key_param) @key_params = .delete(:params) || [] end |
Instance Method Details
#after(cache_path, controller) ⇒ Object
50 51 52 |
# File 'lib/memorize/action.rb', line 50 def after(cache_path, controller) Memorize.cache_store.write cache_path, controller.response.body end |
#before(cache_path, controller) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/memorize/action.rb', line 42 def before(cache_path, controller) if (cache = Memorize.cache_store.read(cache_path)) = {:layout => false, :text => cache} controller.__send__(:render, ) end !!cache end |
#filter(controller, action) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/memorize/action.rb', line 33 def filter(controller, action) cache_path = eval_cache_path(controller) cached = before(cache_path, controller) unless cached action.call after(cache_path, controller) if caching_allowed?(controller) end end |