aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/middleware/flash.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-11-09 00:13:42 +0000
committerJon Leighton <j@jonathanleighton.com>2012-11-09 00:14:13 +0000
commit484283968e8ad7dc8a7864b65603671bec4f2850 (patch)
tree6436ce8f07792aec3ec132fc4abb59d2a827cba7 /actionpack/lib/action_dispatch/middleware/flash.rb
parent648a95b5263401264d4376a3819f9e232dcf3543 (diff)
downloadrails-484283968e8ad7dc8a7864b65603671bec4f2850.tar.gz
rails-484283968e8ad7dc8a7864b65603671bec4f2850.tar.bz2
rails-484283968e8ad7dc8a7864b65603671bec4f2850.zip
Revert "Merge pull request #8017 from jcoglan/objectless_sessions"
This reverts commit 36376560fdd02f955ae3bf6b7792b784443660ad, reversing changes made to 3148ed9a4bb7efef30b846dc945d73ceebcc3f0f. Conflicts: actionpack/lib/action_dispatch/middleware/flash.rb Reason: it broke Sam's CI https://github.com/rails/rails/pull/8017#issuecomment-10210655
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware/flash.rb')
-rw-r--r--actionpack/lib/action_dispatch/middleware/flash.rb33
1 files changed, 9 insertions, 24 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/flash.rb b/actionpack/lib/action_dispatch/middleware/flash.rb
index a162b791e5..9928b7cc3a 100644
--- a/actionpack/lib/action_dispatch/middleware/flash.rb
+++ b/actionpack/lib/action_dispatch/middleware/flash.rb
@@ -4,7 +4,7 @@ module ActionDispatch
# read a notice you put there or <tt>flash["notice"] = "hello"</tt>
# to put a new one.
def flash
- @env[Flash::KEY] ||= Flash::FlashHash.from_session_value(session["flash"])
+ @env[Flash::KEY] ||= (session["flash"] || Flash::FlashHash.new).tap(&:sweep)
end
end
@@ -70,31 +70,16 @@ module ActionDispatch
end
end
+ # Implementation detail: please do not change the signature of the
+ # FlashHash class. Doing that will likely affect all Rails apps in
+ # production as the FlashHash currently stored in their sessions will
+ # become invalid.
class FlashHash
include Enumerable
- def self.from_session_value(value)
- flash = case value
- when FlashHash # Rails 3.1, 3.2
- new(value.instance_variable_get(:@flashes), value.instance_variable_get(:@used))
- when Hash # Rails 4.0
- new(value['flashes'], value['discard'])
- else
- new
- end
-
- flash.sweep
- flash
- end
-
- def to_session_value
- return nil if empty?
- { 'discard' => @discard.to_a, 'flashes' => @flashes }
- end
-
- def initialize(flashes = {}, discard = []) #:nodoc:
- @discard = Set.new(discard)
- @flashes = flashes
+ def initialize #:nodoc:
+ @discard = Set.new
+ @flashes = {}
@now = nil
end
@@ -238,7 +223,7 @@ module ActionDispatch
if flash_hash
if !flash_hash.empty? || session.key?('flash')
- session["flash"] = flash_hash.to_session_value
+ session["flash"] = flash_hash
new_hash = flash_hash.dup
else
new_hash = flash_hash