diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-06 16:27:05 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-06 16:27:05 -0700 |
commit | 0ca69ca65f83b4bb34f81f077c1c38c66ad868b9 (patch) | |
tree | af34afae3d1c62136d6647b90c038f1bbacd9afd /actionpack/lib | |
parent | 9f765f4e0990742519b91d759a6b4374d940ab98 (diff) | |
download | rails-0ca69ca65f83b4bb34f81f077c1c38c66ad868b9.tar.gz rails-0ca69ca65f83b4bb34f81f077c1c38c66ad868b9.tar.bz2 rails-0ca69ca65f83b4bb34f81f077c1c38c66ad868b9.zip |
CookieJar should prefer composition over inheritance
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/cookies.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb index 67c4b83d45..24ebb8fed7 100644 --- a/actionpack/lib/action_dispatch/middleware/cookies.rb +++ b/actionpack/lib/action_dispatch/middleware/cookies.rb @@ -83,7 +83,7 @@ module ActionDispatch # Raised when storing more than 4K of session data. class CookieOverflow < StandardError; end - class CookieJar < Hash #:nodoc: + class CookieJar #:nodoc: # This regular expression is used to split the levels of a domain. # The top level domain can be any string without a period or @@ -116,8 +116,7 @@ module ActionDispatch @host = host @secure = secure @closed = false - - super() + @cookies = {} end attr_reader :closed @@ -126,7 +125,12 @@ module ActionDispatch # Returns the value of the cookie by +name+, or +nil+ if no such cookie exists. def [](name) - super(name.to_s) + @cookies[name.to_s] + end + + def update(other_hash) + @cookies.update other_hash + self end def handle_options(options) #:nodoc: @@ -159,7 +163,7 @@ module ActionDispatch options = { :value => value } end - value = super(key.to_s, value) + value = @cookies[key.to_s] = value handle_options(options) @@ -176,7 +180,7 @@ module ActionDispatch handle_options(options) - value = super(key.to_s) + value = @cookies.delete(key.to_s) @delete_cookies[key] = options value end |