aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/flash.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-02-12 05:51:02 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-02-12 05:51:02 +0000
commit050c3964d8fe8d68c03fff593e3c09b5eae77a46 (patch)
tree9331224443d2415be34543af3a94d415c7020d31 /actionpack/lib/action_controller/flash.rb
parent838ec413ebe08be71eea3dec0b061c6f609c839f (diff)
downloadrails-050c3964d8fe8d68c03fff593e3c09b5eae77a46.tar.gz
rails-050c3964d8fe8d68c03fff593e3c09b5eae77a46.tar.bz2
rails-050c3964d8fe8d68c03fff593e3c09b5eae77a46.zip
Stopped the massive bleeding of concerns into ActionController::Base. Base no longer knows about flash, filters, or components. This may well have introduced some instability, please do test with apps, especially the ones using components. [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3580 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/flash.rb')
-rw-r--r--actionpack/lib/action_controller/flash.rb72
1 files changed, 43 insertions, 29 deletions
diff --git a/actionpack/lib/action_controller/flash.rb b/actionpack/lib/action_controller/flash.rb
index 6a41aa97a6..383263fe92 100644
--- a/actionpack/lib/action_controller/flash.rb
+++ b/actionpack/lib/action_controller/flash.rb
@@ -24,7 +24,16 @@ module ActionController #:nodoc:
#
# See docs on the FlashHash class for more details about the flash.
module Flash
+ def self.included(base)
+ base.send :include, InstanceMethods
+ base.class_eval do
+ alias_method :process_cleanup_without_flash, :process_cleanup
+ alias_method :process_cleanup, :process_cleanup_with_flash
+ end
+ end
+
+
class FlashNow #:nodoc:
def initialize flash
@flash = flash
@@ -52,14 +61,14 @@ module ActionController #:nodoc:
super
end
- def update h #:nodoc:
- h.keys.each{|k| discard k }
+ def update(h) #:nodoc:
+ h.keys.each{ |k| discard(k) }
super
end
- alias merge! update
+ alias :merge! :update
- def replace h #:nodoc:
+ def replace(h) #:nodoc:
@used = {}
super
end
@@ -124,31 +133,36 @@ module ActionController #:nodoc:
end
end
-
- protected
- # Access the contents of the flash. Use <tt>flash["notice"]</tt> to read a notice you put there or
- # <tt>flash["notice"] = "hello"</tt> to put a new one.
- # Note that if sessions are disabled only flash.now will work.
- def flash #:doc:
- @flash ||=
- if @parent_controller
- @parent_controller.flash
- elsif @session.is_a?(Hash)
- # @session is a Hash, if sessions are disabled
- # we don't put the flash in the session in this case
- FlashHash.new
- else
- # otherwise, @session is a CGI::Session or a TestSession
- # so make sure it gets retrieved from/saved to session storage after request processing
- @session["flash"] ||= FlashHash.new
- end
- end
-
- # deprecated. use <tt>flash.keep</tt> instead
- def keep_flash #:doc:
- warn 'keep_flash is deprecated; use flash.keep instead.'
- flash.keep
+ module InstanceMethods
+ def process_cleanup_with_flash
+ process_cleanup_without_flash
+ flash.sweep
end
+
+ protected
+ # Access the contents of the flash. Use <tt>flash["notice"]</tt> to read a notice you put there or
+ # <tt>flash["notice"] = "hello"</tt> to put a new one.
+ # Note that if sessions are disabled only flash.now will work.
+ def flash #:doc:
+ @flash ||=
+ if @parent_controller
+ @parent_controller.flash
+ elsif @session.is_a?(Hash)
+ # @session is a Hash, if sessions are disabled
+ # we don't put the flash in the session in this case
+ FlashHash.new
+ else
+ # otherwise, @session is a CGI::Session or a TestSession
+ # so make sure it gets retrieved from/saved to session storage after request processing
+ @session["flash"] ||= FlashHash.new
+ end
+ end
+ # deprecated. use <tt>flash.keep</tt> instead
+ def keep_flash #:doc:
+ warn 'keep_flash is deprecated; use flash.keep instead.'
+ flash.keep
+ end
+ end
end
-end
+end \ No newline at end of file