aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorScott Barron <scott@elitists.net>2005-10-25 00:38:51 +0000
committerScott Barron <scott@elitists.net>2005-10-25 00:38:51 +0000
commit3a2943c54de7e288ac2443556257df7b2d69ac68 (patch)
treee22b95a51b204eea507839d4bc187ac076cea780 /actionpack/lib
parentf57ba4cc5237b408e23715ab6c7d700bd8e125b0 (diff)
downloadrails-3a2943c54de7e288ac2443556257df7b2d69ac68.tar.gz
rails-3a2943c54de7e288ac2443556257df7b2d69ac68.tar.bz2
rails-3a2943c54de7e288ac2443556257df7b2d69ac68.zip
Take a different approach to keeping flash around when using components.
One that, you know, doesn't involve consuming every byte of free memory on the system. Closes #2589. References #2291. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2722 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/components.rb10
-rw-r--r--actionpack/lib/action_controller/flash.rb4
2 files changed, 11 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/components.rb b/actionpack/lib/action_controller/components.rb
index 312595c21f..62f6ee518d 100644
--- a/actionpack/lib/action_controller/components.rb
+++ b/actionpack/lib/action_controller/components.rb
@@ -50,9 +50,13 @@ module ActionController #:nodoc:
private
def component_response(options, reuse_response = true)
- c = component_class(options)
- c.after_filter {|c| flash.keep }
- c.process(request_for_component(options), reuse_response ? @response : response_for_component)
+ begin
+ ActionController::Flash::FlashHash.avoid_sweep = true
+ Thread.current[:p] = component_class(options).process(request_for_component(options), reuse_response ? @response : response_for_component)
+ ensure
+ ActionController::Flash::FlashHash.avoid_sweep = false
+ end
+ Thread.current[:p]
end
def component_class(options)
diff --git a/actionpack/lib/action_controller/flash.rb b/actionpack/lib/action_controller/flash.rb
index 674f73f1a4..df2863e0b6 100644
--- a/actionpack/lib/action_controller/flash.rb
+++ b/actionpack/lib/action_controller/flash.rb
@@ -43,6 +43,9 @@ module ActionController #:nodoc:
end
class FlashHash < Hash
+ @@avoid_sweep = false
+ cattr_accessor :avoid_sweep
+
def initialize #:nodoc:
super
@used = {}
@@ -99,6 +102,7 @@ module ActionController #:nodoc:
#
# This method is called automatically by filters, so you generally don't need to care about it.
def sweep #:nodoc:
+ return if @@avoid_sweep
keys.each do |k|
unless @used[k]
use(k)