Class: ActionController::Caching::Actions::ActionCacheFilter
- Defined in:
- lib/action_controller/caching.rb
Overview
:nodoc:
Instance Method Summary collapse
- #after(controller) ⇒ Object
- #before(controller) ⇒ Object
-
#initialize(*actions, &block) ⇒ ActionCacheFilter
constructor
A new instance of ActionCacheFilter.
Constructor Details
#initialize(*actions, &block) ⇒ ActionCacheFilter
Returns a new instance of ActionCacheFilter.
229 230 231 232 |
# File 'lib/action_controller/caching.rb', line 229 def initialize(*actions, &block) @options = actions. @actions = Set.new actions end |
Instance Method Details
#after(controller) ⇒ Object
247 248 249 250 |
# File 'lib/action_controller/caching.rb', line 247 def after(controller) return if !@actions.include?(controller.action_name.intern) || controller.rendered_action_cache || !caching_allowed(controller) controller.write_fragment(controller.action_cache_path.path, controller.response.body) end |
#before(controller) ⇒ Object
234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/action_controller/caching.rb', line 234 def before(controller) return unless @actions.include?(controller.action_name.intern) cache_path = ActionCachePath.new(controller, (controller, @options)) if cache = controller.read_fragment(cache_path.path) controller.rendered_action_cache = true set_content_type!(controller, cache_path.extension) controller.send!(:render_for_text, cache) false else controller.action_cache_path = cache_path end end |