Sha256: b9251af6e43091afa215ba303e6219d9a57c14767a2c378c188d44e2ec2b8594
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
require 'omf_common/lobject' module OMF::Web # Keeps session state. # # TODO: Implement cleanup thread # class SessionStore < OMF::Common::LObject @@sessions = {} def self.[](key, domain) self.session["#{domain}:#{key}"] end def self.[]=(key, domain, value) self.session["#{domain}:#{key}"] = value end def self.session() sid = session_id session = @@sessions[sid] ||= {:content => {}} #puts "STORE>> #{sid} = #{session[:content].keys.inspect}" session[:ts] = Time.now session[:content] end def self.session_id sid = Thread.current["sessionID"] raise "Missing session id 'sid'" if sid.nil? sid end def self.find_tab_from_path(comp_path) sid = comp_path.shift unless session = self.session(sid) raise "Can't find session '#{sid}', may have timed out" end tid = comp_path.shift.to_sym unless tab_inst = session[tid] raise "Can't find tab '#{tid}'" end {:sid => sid, :tab_inst => tab_inst, :sub_path => comp_path} end def self.find_across_sessions(&block) @@sessions.values.map { |v| v[:content] }.find(&block) end end # SessionStore end # OMF:Web
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
omf_web-1.0.0 | lib/omf-web/session_store.rb |