Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Abstract id tiny patches #489

Merged
merged 4 commits into from

2 participants

@spastorino
Owner

4 different patches for rack/session/abstract/id

  1. by ivar was renamed to store which I think represents better what is about
  2. there's no need to call generate_sid because session.id after doing load! or if the session was already loaded will always return an id spastorino@c751b47#L0R318
  3. Implement get_session instead of load_session to follow properly the API
  4. Fix current_session_id method doc
@raggi raggi merged commit a4b7caf into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 9 deletions.
  1. +8 −8 lib/rack/session/abstract/id.rb
  2. +1 −1  lib/rack/session/cookie.rb
View
16 lib/rack/session/abstract/id.rb
@@ -24,15 +24,15 @@ class SessionHash
include Enumerable
attr_writer :id
- def initialize(by, env)
- @by = by
+ def initialize(store, env)
+ @store = store
@env = env
@loaded = false
end
def id
return @id if @loaded or instance_variable_defined?(:@id)
- @id = @by.send(:extract_session_id, @env)
+ @id = @store.send(:extract_session_id, @env)
end
def options
@@ -70,7 +70,7 @@ def clear
def destroy
clear
- @id = @by.send(:destroy_session, @env, id, options)
+ @id = @store.send(:destroy_session, @env, id, options)
end
def to_hash
@@ -105,7 +105,7 @@ def inspect
def exists?
return @exists if instance_variable_defined?(:@exists)
@data = {}
- @exists = @by.send(:session_exists?, @env)
+ @exists = @store.send(:session_exists?, @env)
end
def loaded?
@@ -128,7 +128,7 @@ def load_for_write!
end
def load!
- @id, session = @by.send(:load_session, @env)
+ @id, session = @store.send(:load_session, @env)
@data = stringify_keys(session)
@loaded = true
end
@@ -256,7 +256,7 @@ def extract_session_id(env)
sid
end
- # Returns the current session id from the OptionsHash.
+ # Returns the current session id from the SessionHash.
def current_session_id(env)
env[ENV_SESSION_KEY].id
@@ -316,7 +316,7 @@ def commit_session(env, status, headers, body)
return [status, headers, body] unless commit_session?(env, session, options)
session.send(:load!) unless loaded_session?(session)
- session_id ||= session.id || generate_sid
+ session_id ||= session.id
session_data = session.to_hash.delete_if { |k,v| v.nil? }
if not data = set_session(env, session_id, session_data, options)
View
2  lib/rack/session/cookie.rb
@@ -98,7 +98,7 @@ def initialize(app, options={})
private
- def load_session(env)
+ def get_session(env, sid)
data = unpacked_cookie_data(env)
data = persistent_session_id!(data)
[data["session_id"], data]
Something went wrong with that request. Please try again.