Permalink
Browse files

use hash fetches to populate the :id value

  • Loading branch information...
1 parent 0830738 commit 6c6288318a5f0bd8fae0ba599792d35f42ce44b1 @tenderlove tenderlove committed May 2, 2012
Showing with 7 additions and 12 deletions.
  1. +7 −12 actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
@@ -112,23 +112,18 @@ def initialize(by, env, default_options)
end
def [](key)
- load_session_id! if key == :id && session_id_not_loaded?
- @delegate[key]
+ if key == :id
+ @delegate.fetch(key) {
+ @delegate[:id] = @by.send(:extract_session_id, @env)
+ }
+ else
+ @delegate[key]
+ end
end
def []=(k,v); @delegate[k] = v; end
def to_hash; @delegate.dup; end
def values_at(*args) @delegate.values_at(*args); end
-
- private
- def session_id_not_loaded?
- !(@session_id_loaded || @delegate.key?(:id))
- end
-
- def load_session_id!
- @delegate[:id] = @by.send(:extract_session_id, @env)
- @session_id_loaded = true
- end
end
end
end

0 comments on commit 6c62883

Please sign in to comment.