summaryrefslogtreecommitdiff
path: root/lib/cgi/cookie.rb
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-13 22:36:45 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-13 22:36:45 +0000
commit5904f64dbf9b8d78c8431e6ac19663624cbe599e (patch)
treef8c37585890c1b1fed97ce7e70294eeccdc1f0a4 /lib/cgi/cookie.rb
parenta0c569a378389e58b5f54389acf3a83a78ea51ed (diff)
* lib/cgi/cookie.rb (value): Keep CGI::Cookie#value in sync with the cookie itself. Based on a patch by Arthur Schreiber [ruby-core:17634]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/cgi/cookie.rb')
-rw-r--r--lib/cgi/cookie.rb19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/cgi/cookie.rb b/lib/cgi/cookie.rb
index 68fbc8972cc..4588cd0f7a4 100644
--- a/lib/cgi/cookie.rb
+++ b/lib/cgi/cookie.rb
@@ -55,11 +55,10 @@ class CGI
def initialize(name = "", *value)
if name.kind_of?(String)
@name = name
- @value = value
%r|^(.*/)|.match(ENV["SCRIPT_NAME"])
@path = ($1 or "")
@secure = false
- return super(@value)
+ return super(value)
end
options = name
@@ -68,7 +67,7 @@ class CGI
end
@name = options["name"]
- @value = Array(options["value"])
+ value = Array(options["value"])
# simple support for IE
if options["path"]
@path = options["path"]
@@ -80,12 +79,20 @@ class CGI
@expires = options["expires"]
@secure = options["secure"] == true ? true : false
- super(@value)
+ super(value)
end
- attr_accessor("name", "value", "path", "domain", "expires")
+ attr_accessor("name", "path", "domain", "expires")
attr_reader("secure")
+ def value
+ self
+ end
+
+ def value=(val)
+ replace(Array(val))
+ end
+
# Set whether the Cookie is a secure cookie or not.
#
# +val+ must be a boolean.
@@ -96,7 +103,7 @@ class CGI
# Convert the Cookie to its string representation.
def to_s
- val = @value.kind_of?(String) ? CGI::escape(@value) : @value.collect{|v| CGI::escape(v) }.join("&")
+ val = collect{|v| CGI::escape(v) }.join("&")
buf = "#{@name}=#{val}"
buf << "; domain=#{@domain}" if @domain
buf << "; path=#{@path}" if @path