summaryrefslogtreecommitdiffstats
path: root/lib/cgi
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-07-30 14:06:50 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-07-30 14:06:50 +0000
commit17638c89f49d63c117bbbe573138c82f8d35537e (patch)
tree2979f667dea09e484ffc1cff0812cd2837052e8a /lib/cgi
parent6169572584c4fd5baeaeb744a26626730e0fc43c (diff)
downloadruby-17638c89f49d63c117bbbe573138c82f8d35537e.tar.gz
ruby-17638c89f49d63c117bbbe573138c82f8d35537e.tar.xz
ruby-17638c89f49d63c117bbbe573138c82f8d35537e.zip
* lib/cgi/session.rb, lib/cgi/session/pstore.rb: suppress warnings.
fixed: [ruby-talk:204896] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@10643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/cgi')
-rw-r--r--lib/cgi/session.rb16
-rw-r--r--lib/cgi/session/pstore.rb17
2 files changed, 10 insertions, 23 deletions
diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb
index 2bb6571bf..d2a1be4aa 100644
--- a/lib/cgi/session.rb
+++ b/lib/cgi/session.rb
@@ -301,20 +301,14 @@ class CGI
# Retrieve the session data for key +key+.
def [](key)
- unless @data
- @data = @dbman.restore
- end
+ @data ||= @dbman.restore
@data[key]
end
# Set the session date for key +key+.
def []=(key, val)
- unless @write_lock
- @write_lock = true
- end
- unless @data
- @data = @dbman.restore
- end
+ @write_lock ||= true
+ @data ||= @dbman.restore
@data[key] = val
end
@@ -380,7 +374,9 @@ class CGI
require 'digest/md5'
md5 = Digest::MD5.hexdigest(id)[0,16]
@path = dir+"/"+prefix+md5+suffix
- unless File::exist? @path
+ if File::exist? @path
+ @hash = nil
+ else
unless session.new_session
raise CGI::Session::NoSession, "uninitialized session"
end
diff --git a/lib/cgi/session/pstore.rb b/lib/cgi/session/pstore.rb
index a4ef0cbdc..9a16a66b1 100644
--- a/lib/cgi/session/pstore.rb
+++ b/lib/cgi/session/pstore.rb
@@ -14,17 +14,6 @@ require 'pstore'
class CGI
class Session
- def []=(key, val)
- unless @write_lock
- @write_lock = true
- end
- unless @data
- @data = @dbman.restore
- end
- #@data[key] = String(val)
- @data[key] = val
- end
-
# PStore-based session storage class.
#
# This builds upon the top-level PStore class provided by the
@@ -53,7 +42,7 @@ class CGI
#
# This session's PStore file will be created if it does
# not exist, or opened if it does.
- def initialize session, option={}
+ def initialize(session, option={})
dir = option['tmpdir'] || Dir::tmpdir
prefix = option['prefix'] || ''
id = session.session_id
@@ -61,7 +50,9 @@ class CGI
md5 = Digest::MD5.hexdigest(id)[0,16]
path = dir+"/"+prefix+md5
path.untaint
- unless File::exist?(path)
+ if File::exist?(path)
+ @hash = nil
+ else
unless session.new_session
raise CGI::Session::NoSession, "uninitialized session"
end