Class: SWS::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/sws/session.rb

Overview

This is a class representing user sessions. Sessions are based on id, which is passed in cookie

Constant Summary collapse

@@sessions =

Hash for created sessions: key - id, value - Session object (can be subclasses of Session!)

Hash.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#last_access_timeObject

Time when the session was last active



19
20
21
# File 'lib/sws/session.rb', line 19

def last_access_time
  @last_access_time
end

#sidObject (readonly)

Session id



16
17
18
# File 'lib/sws/session.rb', line 16

def sid
  @sid
end

Class Method Details

.delete_session(session) ⇒ Object

Deletes session from registered ones



55
56
57
# File 'lib/sws/session.rb', line 55

def Session.delete_session ( session )
	@@sessions.delete( session.sid )
end

.sessionsObject

Returns sessions Hash containing all registered sessions



49
50
51
# File 'lib/sws/session.rb', line 49

def Session.sessions ()
	return @@sessions
end

Instance Method Details

#add_to_cache(component) ⇒ Object



73
74
75
# File 'lib/sws/session.rb', line 73

def add_to_cache ( component )
	@component_cache.add_component( component )
end

#get_from_cache(component_id) ⇒ Object



77
78
79
# File 'lib/sws/session.rb', line 77

def get_from_cache ( component_id )
	return @component_cache.component( component_id )
end

#old?(component_id) ⇒ Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/sws/session.rb', line 81

def old? ( component_id )
	return @component_cache.old?( component_id )
end

Returns session id represented as cookie in order to append it to response. TODO: deal with “path” (set it to base app path)



63
64
65
# File 'lib/sws/session.rb', line 63

def to_cookie ()
	return Cookie.new( "session",@sid )
end

#to_sObject

Returns string representation of the receiver



69
70
71
# File 'lib/sws/session.rb', line 69

def to_s ()
	return "#{self.class}, sid: #{@sid}"
end