Permalink
Browse files

Sweeper does not belong in Sweeping module

  • Loading branch information...
1 parent 0380e9c commit f7cb7fce4cb25e608f0c2d94a4970c0c7cb7d3da @josh josh committed May 14, 2009
Showing with 37 additions and 35 deletions.
  1. +33 −35 actionpack/lib/action_controller/caching/sweeper.rb
  2. +4 −0 actionpack/test/controller/caching_test.rb
@@ -2,46 +2,44 @@
module ActionController #:nodoc:
module Caching
- module Sweeping
- class Sweeper < ActiveRecord::Observer #:nodoc:
- attr_accessor :controller
+ class Sweeper < ActiveRecord::Observer #:nodoc:
+ attr_accessor :controller
- def before(controller)
- self.controller = controller
- callback(:before) if controller.perform_caching
+ def before(controller)
+ self.controller = controller
+ callback(:before) if controller.perform_caching
+ end
+
+ def after(controller)
+ callback(:after) if controller.perform_caching
+ # Clean up, so that the controller can be collected after this request
+ self.controller = nil
+ end
+
+ protected
+ # gets the action cache path for the given options.
+ def action_path_for(options)
+ ActionController::Caching::Actions::ActionCachePath.path_for(controller, options)
end
- def after(controller)
- callback(:after) if controller.perform_caching
- # Clean up, so that the controller can be collected after this request
- self.controller = nil
+ # Retrieve instance variables set in the controller.
+ def assigns(key)
+ controller.instance_variable_get("@#{key}")
end
- protected
- # gets the action cache path for the given options.
- def action_path_for(options)
- ActionController::Caching::Actions::ActionCachePath.path_for(controller, options)
- end
-
- # Retrieve instance variables set in the controller.
- def assigns(key)
- controller.instance_variable_get("@#{key}")
- end
-
- private
- def callback(timing)
- controller_callback_method_name = "#{timing}_#{controller.controller_name.underscore}"
- action_callback_method_name = "#{controller_callback_method_name}_#{controller.action_name}"
-
- __send__(controller_callback_method_name) if respond_to?(controller_callback_method_name, true)
- __send__(action_callback_method_name) if respond_to?(action_callback_method_name, true)
- end
-
- def method_missing(method, *arguments, &block)
- return if @controller.nil?
- @controller.__send__(method, *arguments, &block)
- end
- end
+ private
+ def callback(timing)
+ controller_callback_method_name = "#{timing}_#{controller.controller_name.underscore}"
+ action_callback_method_name = "#{controller_callback_method_name}_#{controller.action_name}"
+
+ __send__(controller_callback_method_name) if respond_to?(controller_callback_method_name, true)
+ __send__(action_callback_method_name) if respond_to?(action_callback_method_name, true)
+ end
+
+ def method_missing(method, *arguments, &block)
+ return if @controller.nil?
+ @controller.__send__(method, *arguments, &block)
+ end
end
end
end
@@ -8,6 +8,10 @@
ActionController::Base.page_cache_directory = FILE_STORE_PATH
ActionController::Base.cache_store = :file_store, FILE_STORE_PATH
+# Force sweeper classes to load
+ActionController::Caching::Sweeper
+ActionController::Caching::Sweeping
+
class PageCachingTestController < ActionController::Base
caches_page :ok, :no_content, :if => Proc.new { |c| !c.request.format.json? }
caches_page :found, :not_found

0 comments on commit f7cb7fc

Please sign in to comment.