From 654f0d6a1520fc6a0a0396e78255a9ec50594e44 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Thu, 3 Jan 2013 20:28:17 -0500 Subject: extract alert= and notice= examples to FlashHash#now [ci skip] --- actionpack/lib/action_dispatch/middleware/flash.rb | 32 ++++++++++------------ 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/middleware/flash.rb b/actionpack/lib/action_dispatch/middleware/flash.rb index 7e00510fa8..7e56feb90a 100644 --- a/actionpack/lib/action_dispatch/middleware/flash.rb +++ b/actionpack/lib/action_dispatch/middleware/flash.rb @@ -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 flash.now[:alert]=. 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 flash.now[:notice]=. 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 now are accessed the same way as standard entries: flash['my-key']. + # + # 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 flash[:alert]. def alert self[:alert] end - # Convenience accessor for flash[:alert]= + # Convenience accessor for flash[:alert]=. def alert=(message) self[:alert] = message end - # Convenience accessor for flash[:notice] + # Convenience accessor for flash[:notice]. def notice self[:notice] end - # Convenience accessor for flash[:notice]= + # Convenience accessor for flash[:notice]=. def notice=(message) self[:notice] = message end -- cgit v1.2.3