mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
extract alert= and notice= examples to FlashHash#now [ci skip]
This commit is contained in:
parent
dc14b893e5
commit
654f0d6a15
1 changed files with 15 additions and 17 deletions
|
@ -59,22 +59,12 @@ module ActionDispatch
|
|||
@flash[k]
|
||||
end
|
||||
|
||||
# Convenience accessor for flash.now[:alert]=
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# flash.alert = "Error: no cheezburger"
|
||||
# # Equivlant to flash[:alert] = "No cheezburger"
|
||||
# Convenience accessor for <tt>flash.now[:alert]=</tt>.
|
||||
def alert=(message)
|
||||
self[:alert] = message
|
||||
end
|
||||
|
||||
# Convenience accessor for flash.now[:notice]=
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# flash.notice = "Bukkit stolen"
|
||||
# # Equivlant to flash[:notice] = "Bukkit stolen"
|
||||
# Convenience accessor for <tt>flash.now[:notice]=</tt>.
|
||||
def notice=(message)
|
||||
self[:notice] = message
|
||||
end
|
||||
|
@ -92,7 +82,7 @@ module ActionDispatch
|
|||
else
|
||||
new
|
||||
end
|
||||
|
||||
|
||||
flash.tap(&:sweep)
|
||||
end
|
||||
|
||||
|
@ -179,6 +169,14 @@ module ActionDispatch
|
|||
# vanish when the current action is done.
|
||||
#
|
||||
# Entries set via <tt>now</tt> are accessed the same way as standard entries: <tt>flash['my-key']</tt>.
|
||||
#
|
||||
# Also, brings two convenience accessors:
|
||||
#
|
||||
# flash.now.alert = "Beware now!"
|
||||
# # Equivalent to flash.now[:alert] = "Beware now!"
|
||||
#
|
||||
# flash.now.notice = "Good luck now!"
|
||||
# # Equivalent to flash.now[:notice] = "Good luck now!"
|
||||
def now
|
||||
@now ||= FlashNow.new(self)
|
||||
end
|
||||
|
@ -209,22 +207,22 @@ module ActionDispatch
|
|||
@discard.replace @flashes.keys
|
||||
end
|
||||
|
||||
# Convenience accessor for flash[:alert]
|
||||
# Convenience accessor for <tt>flash[:alert]</tt>.
|
||||
def alert
|
||||
self[:alert]
|
||||
end
|
||||
|
||||
# Convenience accessor for flash[:alert]=
|
||||
# Convenience accessor for <tt>flash[:alert]=</tt>.
|
||||
def alert=(message)
|
||||
self[:alert] = message
|
||||
end
|
||||
|
||||
# Convenience accessor for flash[:notice]
|
||||
# Convenience accessor for <tt>flash[:notice]</tt>.
|
||||
def notice
|
||||
self[:notice]
|
||||
end
|
||||
|
||||
# Convenience accessor for flash[:notice]=
|
||||
# Convenience accessor for <tt>flash[:notice]=</tt>.
|
||||
def notice=(message)
|
||||
self[:notice] = message
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue