From 6b0a6472365a7b9c3883d2de3ae19b49e77c847f Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 9 Sep 2007 21:54:59 +0000 Subject: [PATCH] Removed ActionController::Base#keep_flash (use flash.keep instead) git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7428 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/flash.rb | 26 +++++++++-------------- actionpack/test/controller/flash_test.rb | 4 ++-- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/actionpack/lib/action_controller/flash.rb b/actionpack/lib/action_controller/flash.rb index 314d32e9f5..b3e39912ce 100644 --- a/actionpack/lib/action_controller/flash.rb +++ b/actionpack/lib/action_controller/flash.rb @@ -1,8 +1,8 @@ module ActionController #:nodoc: # The flash provides a way to pass temporary objects between actions. Anything you place in the flash will be exposed - # to the very next action and then cleared out. This is a great way of doing notices and alerts, such as a create action - # that sets flash[:notice] = "Successfully created" before redirecting to a display action that can then expose - # the flash to its template. Actually, that exposure is automatically done. Example: + # to the very next action and then cleared out. This is a great way of doing notices and alerts, such as a create + # action that sets flash[:notice] = "Successfully created" before redirecting to a display action that can + # then expose the flash to its template. Actually, that exposure is automatically done. Example: # # class WeblogController < ActionController::Base # def create @@ -19,8 +19,8 @@ module ActionController #:nodoc: # display.erb # <% if flash[:notice] %>
<%= flash[:notice] %>
<% end %> # - # This example just places a string in the flash, but you can put any object in there. And of course, you can put as many - # as you like at a time too. Just remember: They'll be gone by the time the next action has been performed. + # This example just places a string in the flash, but you can put any object in there. And of course, you can put as + # many as you like at a time too. Just remember: They'll be gone by the time the next action has been performed. # # See docs on the FlashHash class for more details about the flash. module Flash @@ -85,7 +85,7 @@ def replace(h) #:nodoc: # # Entries set via now are accessed the same way as standard entries: flash['my-key']. def now - FlashNow.new self + FlashNow.new(self) end # Keeps either the entire current flash or a specific flash entry available for the next action: @@ -117,7 +117,8 @@ def sweep #:nodoc: end end - (@used.keys - keys).each{|k| @used.delete k } # clean up after keys that could have been left over by calling reject! or shift on the flash + # clean up after keys that could have been left over by calling reject! or shift on the flash + (@used.keys - keys).each{ |k| @used.delete(k) } end private @@ -130,13 +131,12 @@ def use(k=nil, v=true) unless k.nil? @used[k] = v else - keys.each{|key| use key, v } + keys.each{ |key| use(key, v) } end end end module InstanceMethods #:nodoc: - protected def reset_session_with_flash reset_session_without_flash @@ -163,12 +163,6 @@ def flash(refresh = false) #:doc: @_flash end - # deprecated. use flash.keep instead - def keep_flash #:doc: - ActiveSupport::Deprecation.warn 'keep_flash is deprecated; use flash.keep instead.', caller - flash.keep - end - private def assign_shortcuts_with_flash(request, response) #:nodoc: assign_shortcuts_without_flash(request, response) @@ -181,4 +175,4 @@ def process_cleanup_with_flash end end end -end +end \ No newline at end of file diff --git a/actionpack/test/controller/flash_test.rb b/actionpack/test/controller/flash_test.rb index 496af2b47a..35ab1b9d3c 100644 --- a/actionpack/test/controller/flash_test.rb +++ b/actionpack/test/controller/flash_test.rb @@ -31,7 +31,7 @@ def use_flash def use_flash_and_keep_it @flash_copy = {}.update flash @flashy = flash["that"] - silence_warnings { keep_flash } + flash.keep render :inline => "hello" end @@ -94,7 +94,7 @@ def test_flash def test_keep_flash get :set_flash - assert_deprecated(/keep_flash/) { get :use_flash_and_keep_it } + get :use_flash_and_keep_it assert_equal "hello", @response.template.assigns["flash_copy"]["that"] assert_equal "hello", @response.template.assigns["flashy"] -- GitLab