Created
May 14, 2011 02:17
-
-
Save AquaGeek/971647 to your computer and use it in GitHub Desktop.
Rails Lighthouse ticket #3457
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 1030aa7783a5583b85bc78a9724560b894ef9e04 Mon Sep 17 00:00:00 2001 | |
From: Blythe Dunham <[email protected]> | |
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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment