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.



184
185
186
# File 'lib/action_controller/caching.rb', line 184

def initialize(*actions)
  @actions = actions
end

Instance Method Details

#after(controller) ⇒ Object



197
198
199
200
# File 'lib/action_controller/caching.rb', line 197

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



188
189
190
191
192
193
194
195
# File 'lib/action_controller/caching.rb', line 188

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