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 3e9cb66 commit d49aa81
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 @@ -14,11 +14,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 @@ -299,7 +294,7 @@ def prepare_session(env)
def load_session(env)
sid = current_session_id(env)
sid, session = get_session(env, sid)
[sid || NullSessionId.new, session || {}]
[sid, session || {}]
end

# Extract session id from request object.
Expand All @@ -308,7 +303,7 @@ def extract_session_id(env)
request = Rack::Request.new(env)
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 @@ -126,7 +126,7 @@ def get_session(env, sid)
end

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

def unpacked_cookie_data(env)
Expand Down Expand Up @@ -178,11 +178,7 @@ def set_session(env, session_id, session, options)

def destroy_session(env, 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 set_session(env, session_id, new_session, options)
def destroy_session(env, session_id, options)
with_lock(env) 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 d49aa81

Please sign in to comment.