aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-06-13 14:12:44 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-06-13 14:12:44 -0700
commit3692ca5ce7a0dbb11c4001891488905c53fbc5e5 (patch)
treedac9f689b793e6442a94b63aa9d892caf6e8b6b1 /actionpack
parentdef14505b717d8ef36c80e40f17dab54ec331d05 (diff)
downloadrails-3692ca5ce7a0dbb11c4001891488905c53fbc5e5.tar.gz
rails-3692ca5ce7a0dbb11c4001891488905c53fbc5e5.tar.bz2
rails-3692ca5ce7a0dbb11c4001891488905c53fbc5e5.zip
don't hold a reference to `env` in the options object
I want to decouple Rails from the rack ENV as much as possible. We should try to keep as few references to the env as possible
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/request/session.rb24
1 files changed, 11 insertions, 13 deletions
diff --git a/actionpack/lib/action_dispatch/request/session.rb b/actionpack/lib/action_dispatch/request/session.rb
index 773d41de88..a8a3cd20b9 100644
--- a/actionpack/lib/action_dispatch/request/session.rb
+++ b/actionpack/lib/action_dispatch/request/session.rb
@@ -17,7 +17,7 @@ module ActionDispatch
session.merge! session_was if session_was
set(env, session)
- Options.set(env, Request::Session::Options.new(store, env, default_options))
+ Options.set(env, Request::Session::Options.new(store, default_options))
session
end
@@ -38,20 +38,19 @@ module ActionDispatch
env[ENV_SESSION_OPTIONS_KEY]
end
- def initialize(by, env, default_options)
+ def initialize(by, default_options)
@by = by
- @env = env
@delegate = default_options.dup
end
def [](key)
- if key == :id
- @delegate.fetch(key) {
- @delegate[:id] = @by.send(:extract_session_id, @env)
- }
- else
- @delegate[key]
- end
+ @delegate[key]
+ end
+
+ def id(env)
+ @delegate.fetch(:id) {
+ @by.send(:extract_session_id, env)
+ }
end
def []=(k,v); @delegate[k] = v; end
@@ -68,7 +67,7 @@ module ActionDispatch
end
def id
- options[:id]
+ options.id(@env)
end
def options
@@ -78,8 +77,7 @@ module ActionDispatch
def destroy
clear
options = self.options || {}
- new_sid = @by.send(:destroy_session, @env, options[:id], options)
- options[:id] = new_sid # Reset session id with a new value or nil
+ @by.send(:destroy_session, @env, options.id(@env), options)
# Load the new sid to be written with the response
@loaded = false