aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/request
diff options
context:
space:
mode:
authorTom Prats <tprats108@gmail.com>2016-01-30 19:30:32 -0500
committerTom Prats <tprats108@gmail.com>2016-01-30 19:30:32 -0500
commit45a75a3fcc96b22954caf69be2df4e302b134d7a (patch)
tree1f4ef44ceb84e9aebb264c85c976cae0db661d09 /actionpack/lib/action_dispatch/request
parent82dc8266dddc199789f3f1e9a9f21975e1c8ee87 (diff)
downloadrails-45a75a3fcc96b22954caf69be2df4e302b134d7a.tar.gz
rails-45a75a3fcc96b22954caf69be2df4e302b134d7a.tar.bz2
rails-45a75a3fcc96b22954caf69be2df4e302b134d7a.zip
Update Session to utilize indiffernt access
Diffstat (limited to 'actionpack/lib/action_dispatch/request')
-rw-r--r--actionpack/lib/action_dispatch/request/session.rb22
1 files changed, 8 insertions, 14 deletions
diff --git a/actionpack/lib/action_dispatch/request/session.rb b/actionpack/lib/action_dispatch/request/session.rb
index f6428af636..38d0da3e67 100644
--- a/actionpack/lib/action_dispatch/request/session.rb
+++ b/actionpack/lib/action_dispatch/request/session.rb
@@ -88,13 +88,13 @@ module ActionDispatch
# nil if the given key is not found in the session.
def [](key)
load_for_read!
- @delegate[key.to_s]
+ @delegate[key]
end
# Returns true if the session has the given key or false.
def has_key?(key)
load_for_read!
- @delegate.key?(key.to_s)
+ @delegate.key?(key)
end
alias :key? :has_key?
alias :include? :has_key?
@@ -112,7 +112,7 @@ module ActionDispatch
# Writes given value to given key of the session.
def []=(key, value)
load_for_write!
- @delegate[key.to_s] = value
+ @delegate[key] = value
end
# Clears the session.
@@ -139,13 +139,13 @@ module ActionDispatch
# # => {"session_id"=>"e29b9ea315edf98aad94cc78c34cc9b2", "foo" => "bar"}
def update(hash)
load_for_write!
- @delegate.update stringify_keys(hash)
+ @delegate.update hash
end
# Deletes given key from the session.
def delete(key)
load_for_write!
- @delegate.delete key.to_s
+ @delegate.delete key
end
# Returns value of the given key from the session, or raises +KeyError+
@@ -165,9 +165,9 @@ module ActionDispatch
def fetch(key, default=Unspecified, &block)
load_for_read!
if default == Unspecified
- @delegate.fetch(key.to_s, &block)
+ @delegate.fetch(key, &block)
else
- @delegate.fetch(key.to_s, default, &block)
+ @delegate.fetch(key, default, &block)
end
end
@@ -211,15 +211,9 @@ module ActionDispatch
def load!
id, session = @by.load_session @req
options[:id] = id
- @delegate.replace(stringify_keys(session))
+ @delegate.replace(session)
@loaded = true
end
-
- def stringify_keys(other)
- other.each_with_object({}) { |(key, value), hash|
- hash[key.to_s] = value
- }
- end
end
end
end