From 1030aa7783a5583b85bc78a9724560b894ef9e04 Mon Sep 17 00:00:00 2001 From: Blythe Dunham Date: Wed, 4 Nov 2009 12:49:57 -0800 Subject: [PATCH] Use Thread.current for sweeper controller --- .../lib/action_controller/caching/sweeping.rb | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/actionpack/lib/action_controller/caching/sweeping.rb b/actionpack/lib/action_controller/caching/sweeping.rb index 871f41b..bc3e2e5 100644 --- a/actionpack/lib/action_controller/caching/sweeping.rb +++ b/actionpack/lib/action_controller/caching/sweeping.rb @@ -54,7 +54,13 @@ module ActionController #:nodoc: if defined?(ActiveRecord) and defined?(ActiveRecord::Observer) class Sweeper < ActiveRecord::Observer #:nodoc: - attr_accessor :controller + def controller + Thread.current["#{self.class.name}_controller"] + end + + def controller=(controller) + Thread.current["#{self.class.name}_controller"] = controller + end def before(controller) self.controller = controller @@ -88,8 +94,8 @@ module ActionController #:nodoc: end def method_missing(method, *arguments, &block) - return if @controller.nil? - @controller.__send__(method, *arguments, &block) + return if controller.nil? + controller.__send__(method, *arguments, &block) end end end -- 1.6.5