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, &block) ⇒ ActionCacheFilter

Returns a new instance of ActionCacheFilter.



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

def initialize(*actions, &block)
  @actions = actions
end

Instance Method Details

#after(controller) ⇒ Object



203
204
205
206
# File 'lib/action_controller/caching.rb', line 203

def after(controller)
  return if !@actions.include?(controller.action_name.intern) || controller.rendered_action_cache
  controller.write_fragment(ActionCachePath.path_for(controller), controller.response.body)
end

#before(controller) ⇒ Object



192
193
194
195
196
197
198
199
200
201
# File 'lib/action_controller/caching.rb', line 192

def before(controller)
  return unless @actions.include?(controller.action_name.intern)
  action_cache_path = ActionCachePath.new(controller)
  if cache = controller.read_fragment(action_cache_path.path)
    controller.rendered_action_cache = true
    set_content_type!(action_cache_path)
    controller.send(:render_text, cache)
    false
  end
end