aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/middleware
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware')
-rw-r--r--actionpack/lib/action_dispatch/middleware/session/abstract_store.rb19
1 files changed, 7 insertions, 12 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb b/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
index 56c71b962a..6dd554ee49 100644
--- a/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
+++ b/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
@@ -112,23 +112,18 @@ module ActionDispatch
end
def [](key)
- load_session_id! if key == :id && session_id_not_loaded?
- @delegate[key]
+ if key == :id
+ @delegate.fetch(key) {
+ @delegate[:id] = @by.send(:extract_session_id, @env)
+ }
+ else
+ @delegate[key]
+ end
end
def []=(k,v); @delegate[k] = v; end
def to_hash; @delegate.dup; end
def values_at(*args) @delegate.values_at(*args); end
-
- private
- def session_id_not_loaded?
- !(@session_id_loaded || @delegate.key?(:id))
- end
-
- def load_session_id!
- @delegate[:id] = @by.send(:extract_session_id, @env)
- @session_id_loaded = true
- end
end
end
end