Skip to content

Commit

Permalink
remove NullSession
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Dec 17, 2019
1 parent 1c7e3b2 commit 4e32262
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
9 changes: 2 additions & 7 deletions lib/rack/session/abstract/id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ module Rack

module Session

class NullSessionId
def empty?; true; end
def nil?; true; end
end

class SessionId
attr_reader :public_id

Expand Down Expand Up @@ -313,15 +308,15 @@ def prepare_session(req)
def load_session(req)
sid = current_session_id(req)
sid, session = find_session(req, sid)
[sid || NullSessionId.new, session || {}]
[sid, session || {}]
end

# Extract session id from request object.

def extract_session_id(request)
sid = request.cookies[@key]
sid ||= request.params[@key] unless @cookie_only
(sid && SessionId.new(sid)) || NullSessionId.new
sid && SessionId.new(sid)
end

# Returns the current session id from the SessionHash.
Expand Down
8 changes: 2 additions & 6 deletions lib/rack/session/cookie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def find_session(req, sid)
end

def extract_session_id(request)
unpacked_cookie_data(request)["session_id"] || NullSessionId.new
unpacked_cookie_data(request)["session_id"]
end

def unpacked_cookie_data(request)
Expand Down Expand Up @@ -180,11 +180,7 @@ def write_session(req, session_id, session, options)

def delete_session(req, session_id, options)
# Nothing to do here, data is in the client
if options[:drop]
NullSessionId.new
else
generate_sid
end
generate_sid unless options[:drop]
end

def digest_match?(data, digest)
Expand Down
6 changes: 1 addition & 5 deletions lib/rack/session/pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ def write_session(req, session_id, new_session, options)
def delete_session(req, session_id, options)
with_lock(req) do
@pool.delete(session_id.private_id)
if options[:drop]
NullSessionId.new
else
generate_sid
end
generate_sid unless options[:drop]
end
end

Expand Down

0 comments on commit 4e32262

Please sign in to comment.