Permalink
Browse files

Clear empty nil values in session hash before saving

  • Loading branch information...
1 parent ed70830 commit 43ac42c46a462e1453b1b97da00e11bff7bba55d @josh josh committed Dec 16, 2008
@@ -32,7 +32,9 @@ def []=(key, value)
end
def to_hash
- {}.replace(self)
+ h = {}.replace(self)
+ h.delete_if { |k,v| v.nil? }
+ h
end
private
@@ -74,30 +74,11 @@ def initialize(app, options = {})
freeze
end
- class SessionHash < Hash
- def initialize(middleware, env)
- @middleware = middleware
- @env = env
- @loaded = false
- end
-
- def [](key)
- load! unless @loaded
- super
- end
-
- def []=(key, value)
- load! unless @loaded
- super
- end
-
- def to_hash
- {}.replace(self)
- end
-
+ class SessionHash < AbstractStore::SessionHash
private
def load!
- replace(@middleware.send(:load_session, @env))
+ session = @by.send(:load_session, @env)
+ replace(session)
@loaded = true
end
end

0 comments on commit 43ac42c

Please sign in to comment.