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.



181
182
183
# File 'lib/action_controller/caching.rb', line 181

def initialize(*actions)
  @actions = actions
end

Instance Method Details

#after(controller) ⇒ Object



194
195
196
197
# File 'lib/action_controller/caching.rb', line 194

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



185
186
187
188
189
190
191
192
# File 'lib/action_controller/caching.rb', line 185

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