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
上级 b7c565dc
module ActionController #:nodoc: module ActionController #:nodoc:
# The flash provides a way to pass temporary objects between actions. Anything you place in the flash will be exposed # 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 # to the very next action and then cleared out. This is a great way of doing notices and alerts, such as a create
# that sets <tt>flash[:notice] = "Successfully created"</tt> before redirecting to a display action that can then expose # action that sets <tt>flash[:notice] = "Successfully created"</tt> before redirecting to a display action that can
# the flash to its template. Actually, that exposure is automatically done. Example: # then expose the flash to its template. Actually, that exposure is automatically done. Example:
# #
# class WeblogController < ActionController::Base # class WeblogController < ActionController::Base
# def create # def create
...@@ -19,8 +19,8 @@ module ActionController #:nodoc: ...@@ -19,8 +19,8 @@ module ActionController #:nodoc:
# display.erb # display.erb
# <% if flash[:notice] %><div class="notice"><%= flash[:notice] %></div><% end %> # <% if flash[:notice] %><div class="notice"><%= flash[:notice] %></div><% 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 # This example just places a string in the flash, but you can put any object in there. And of course, you can put as
# as you like at a time too. Just remember: They'll be gone by the time the next action has been performed. # 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. # See docs on the FlashHash class for more details about the flash.
module Flash module Flash
...@@ -85,7 +85,7 @@ def replace(h) #:nodoc: ...@@ -85,7 +85,7 @@ def replace(h) #:nodoc:
# #
# Entries set via <tt>now</tt> are accessed the same way as standard entries: <tt>flash['my-key']</tt>. # Entries set via <tt>now</tt> are accessed the same way as standard entries: <tt>flash['my-key']</tt>.
def now def now
FlashNow.new self FlashNow.new(self)
end end
# Keeps either the entire current flash or a specific flash entry available for the next action: # Keeps either the entire current flash or a specific flash entry available for the next action:
...@@ -117,7 +117,8 @@ def sweep #:nodoc: ...@@ -117,7 +117,8 @@ def sweep #:nodoc:
end end
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 end
private private
...@@ -130,13 +131,12 @@ def use(k=nil, v=true) ...@@ -130,13 +131,12 @@ def use(k=nil, v=true)
unless k.nil? unless k.nil?
@used[k] = v @used[k] = v
else else
keys.each{|key| use key, v } keys.each{ |key| use(key, v) }
end end
end end
end end
module InstanceMethods #:nodoc: module InstanceMethods #:nodoc:
protected protected
def reset_session_with_flash def reset_session_with_flash
reset_session_without_flash reset_session_without_flash
...@@ -163,12 +163,6 @@ def flash(refresh = false) #:doc: ...@@ -163,12 +163,6 @@ def flash(refresh = false) #:doc:
@_flash @_flash
end end
# deprecated. use <tt>flash.keep</tt> instead
def keep_flash #:doc:
ActiveSupport::Deprecation.warn 'keep_flash is deprecated; use flash.keep instead.', caller
flash.keep
end
private private
def assign_shortcuts_with_flash(request, response) #:nodoc: def assign_shortcuts_with_flash(request, response) #:nodoc:
assign_shortcuts_without_flash(request, response) assign_shortcuts_without_flash(request, response)
...@@ -181,4 +175,4 @@ def process_cleanup_with_flash ...@@ -181,4 +175,4 @@ def process_cleanup_with_flash
end end
end end
end end
end end
\ No newline at end of file
...@@ -31,7 +31,7 @@ def use_flash ...@@ -31,7 +31,7 @@ def use_flash
def use_flash_and_keep_it def use_flash_and_keep_it
@flash_copy = {}.update flash @flash_copy = {}.update flash
@flashy = flash["that"] @flashy = flash["that"]
silence_warnings { keep_flash } flash.keep
render :inline => "hello" render :inline => "hello"
end end
...@@ -94,7 +94,7 @@ def test_flash ...@@ -94,7 +94,7 @@ def test_flash
def test_keep_flash def test_keep_flash
get :set_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["flash_copy"]["that"]
assert_equal "hello", @response.template.assigns["flashy"] assert_equal "hello", @response.template.assigns["flashy"]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册