Sha256: 5ebd71a600937275d12ae26d1e51514aa9bb1f4f91676774511affdc7d143c66
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
require 'omf_base/lobject' module OMF::Web # Keeps session state. # # TODO: Implement cleanup thread # class SessionStore < OMF::Base::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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
omf_web-1.2.1 | lib/omf-web/session_store.rb |
omf_web-1.2.0 | lib/omf-web/session_store.rb |