Class: ActionController::Caching::Actions::ActionCacheFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/action_controller/caching.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(*actions) ⇒ ActionCacheFilter

Returns a new instance of ActionCacheFilter.



173
174
175
# File 'lib/action_controller/caching.rb', line 173

def initialize(*actions)
  @actions = actions
end

Instance Method Details

#after(controller) ⇒ Object



186
187
188
189
# File 'lib/action_controller/caching.rb', line 186

def after(controller)
  return if !@actions.include?(controller.action_name.intern) || controller.rendered_action_cache
  controller.write_fragment(controller.url_for.split("://").last, controller.response.body)
end

#before(controller) ⇒ Object



177
178
179
180
181
182
183
184
# File 'lib/action_controller/caching.rb', line 177

def before(controller)
  return unless @actions.include?(controller.action_name.intern)
  if cache = controller.read_fragment(controller.url_for.split("://").last)
    controller.rendered_action_cache = true
    controller.send(:render_text, cache)
    false
  end
end