summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-01-04 14:23:17 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2012-01-04 14:23:17 +0100
commitfd132ece1fc6792eaf4872703ad40fe926ed3434 (patch)
treef78049bb57cb56574f14481b78a332211ee0101c
parente44528d5ff7fbb5d2698baf6443c145bcf98b309 (diff)
downloadzorglub-fd132ece1fc6792eaf4872703ad40fe926ed3434.zip
zorglub-fd132ece1fc6792eaf4872703ad40fe926ed3434.tar.gz
session: remove #exists?, add #sid
-rw-r--r--lib/zorglub/session.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/zorglub/session.rb b/lib/zorglub/session.rb
index da2c3f0..a20dfcc 100644
--- a/lib/zorglub/session.rb
+++ b/lib/zorglub/session.rb
@@ -16,17 +16,18 @@ module Zorglub
@data = {}
class << self
attr_reader :data
+ def sid_exists? sid
+ not @data[sid].nil?
+ end
end
#
+ attr_reader :sid
+ #
def initialize sid
@sid = sid
- # TODO if sid is nil, one should be created
@session_data = SessionHash.data[sid]||={}
end
#
- def exists?
- not @sid.nil?
- end
#
def [] idx
@session_data[idx]
@@ -65,18 +66,21 @@ module Zorglub
end
private :setup!
#
- def exists?
+ def sid
setup! if @instance.nil?
- @instance.exists?
+ return nil if @instance.nil?
+ @instance.sid
end
#
def [] idx
setup! if @instance.nil?
+ return nil if @instance.nil?
@instance[idx]
end
#
def []= idx, v
setup! if @instance.nil?
+ return nil if @instance.nil?
@instance[idx] = v
end
#