aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/flash.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-04-17 11:38:01 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-04-17 11:38:01 +0000
commitdca7efa67ec12b986ed03844af588055c9d8bdb9 (patch)
tree13207b1dce3af68528ddfe11d32ee98f627eb0a0 /actionpack/lib/action_controller/flash.rb
parentd5b67ed8d33dbde44d24d7d93135261062e550d1 (diff)
downloadrails-dca7efa67ec12b986ed03844af588055c9d8bdb9.tar.gz
rails-dca7efa67ec12b986ed03844af588055c9d8bdb9.tar.bz2
rails-dca7efa67ec12b986ed03844af588055c9d8bdb9.zip
Deprecated the majority of all the testing assertions and replaced them with a much smaller core and access to all the collections the old assertions relied on. That way the regular test/unit assertions can be used against these. Added documentation about how to use it all.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1189 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/flash.rb')
-rw-r--r--actionpack/lib/action_controller/flash.rb66
1 files changed, 30 insertions, 36 deletions
diff --git a/actionpack/lib/action_controller/flash.rb b/actionpack/lib/action_controller/flash.rb
index e3a8a8c8c4..90c464dd81 100644
--- a/actionpack/lib/action_controller/flash.rb
+++ b/actionpack/lib/action_controller/flash.rb
@@ -24,7 +24,6 @@ module ActionController #:nodoc:
#
# See docs on the FlashHash class for more details about the flash.
module Flash
-
def self.append_features(base) #:nodoc:
super
base.before_filter(:fire_flash)
@@ -44,7 +43,6 @@ module ActionController #:nodoc:
end
class FlashHash < Hash
-
def initialize #:nodoc:
super
@used = {}
@@ -113,49 +111,45 @@ module ActionController #:nodoc:
end
private
-
- # Used internally by the <tt>keep</tt> and <tt>discard</tt> methods
- # use() # marks the entire flash as used
- # use('msg') # marks the "msg" entry as used
- # use(nil, false) # marks the entire flash as unused (keeps it around for one more action)
- # use('msg', false) # marks the "msg" entry as unused (keeps it around for one more action)
- def use(k=nil, v=true)
- unless k.nil?
- @used[k] = v
- else
- keys.each{|key| use key, v }
+ # Used internally by the <tt>keep</tt> and <tt>discard</tt> methods
+ # use() # marks the entire flash as used
+ # use('msg') # marks the "msg" entry as used
+ # use(nil, false) # marks the entire flash as unused (keeps it around for one more action)
+ # use('msg', false) # marks the "msg" entry as unused (keeps it around for one more action)
+ def use(k=nil, v=true)
+ unless k.nil?
+ @used[k] = v
+ else
+ keys.each{|key| use key, v }
+ end
end
- 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.
+ def flash #:doc:
+ @session['flash'] ||= FlashHash.new
+ end
- # 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.
- def flash #:doc:
- @session['flash'] ||= FlashHash.new
- end
-
- # deprecated. use <tt>flash.keep</tt> instead
- def keep_flash #:doc:
- flash.keep
- end
-
+ # deprecated. use <tt>flash.keep</tt> instead
+ def keep_flash #:doc:
+ flash.keep
+ end
- private
- # marks flash entries as used and expose the flash to the view
- def fire_flash
- flash.discard
- @assigns["flash"] = flash
- end
+ private
- # deletes the flash entries that were not marked for keeping
- def sweep_flash
- flash.sweep
- end
+ # marks flash entries as used and expose the flash to the view
+ def fire_flash
+ flash.discard
+ @assigns["flash"] = flash
+ end
+ # deletes the flash entries that were not marked for keeping
+ def sweep_flash
+ flash.sweep
+ end
end
end