diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-08-07 07:39:09 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-08-07 07:55:19 -0700 |
commit | 85969c74cdd29776790165b7ef1d833ccacb1585 (patch) | |
tree | 5084f47f3aae5829c9d1db819198a9e8c4b35ce6 /actionpack | |
parent | b3f5d3c7b2589da45c09aa2a716be10a8213510d (diff) | |
download | rails-85969c74cdd29776790165b7ef1d833ccacb1585.tar.gz rails-85969c74cdd29776790165b7ef1d833ccacb1585.tar.bz2 rails-85969c74cdd29776790165b7ef1d833ccacb1585.zip |
move flash hash access to methods on the request object
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/flash.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/flash.rb b/actionpack/lib/action_dispatch/middleware/flash.rb index 59639a010e..23da169b22 100644 --- a/actionpack/lib/action_dispatch/middleware/flash.rb +++ b/actionpack/lib/action_dispatch/middleware/flash.rb @@ -8,6 +8,14 @@ module ActionDispatch def flash @env[Flash::KEY] ||= Flash::FlashHash.from_session_value(session["flash"]) end + + def flash=(flash) + @env[Flash::KEY] = flash + end + + def flash_hash # :nodoc: + @env[Flash::KEY] + end end # The flash provides a way to pass temporary primitive-types (String, Array, Hash) between actions. Anything you place in the flash will be exposed @@ -263,14 +271,15 @@ module ActionDispatch end def call(env) + req = ActionDispatch::Request.new env @app.call(env) ensure session = Request::Session.find(env) || {} - flash_hash = env[KEY] + flash_hash = req.flash_hash if flash_hash && (flash_hash.present? || session.key?('flash')) session["flash"] = flash_hash.to_session_value - env[KEY] = flash_hash.dup + req.flash = flash_hash.dup end if (!session.respond_to?(:loaded?) || session.loaded?) && # (reset_session uses {}, which doesn't implement #loaded?) |