From 3a2943c54de7e288ac2443556257df7b2d69ac68 Mon Sep 17 00:00:00 2001 From: Scott Barron Date: Tue, 25 Oct 2005 00:38:51 +0000 Subject: 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 --- actionpack/lib/action_controller/components.rb | 10 +++++++--- actionpack/lib/action_controller/flash.rb | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'actionpack/lib') 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) -- cgit v1.2.3