Class: SWS::Session
- Inherits:
-
Object
- Object
- SWS::Session
- 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
-
#last_access_time ⇒ Object
Time when the session was last active.
-
#sid ⇒ Object
readonly
Session id.
Class Method Summary collapse
-
.delete_session(session) ⇒ Object
Deletes session from registered ones.
-
.sessions ⇒ Object
Returns sessions Hash containing all registered sessions.
Instance Method Summary collapse
- #add_to_cache(component) ⇒ Object
- #get_from_cache(component_id) ⇒ Object
- #old?(component_id) ⇒ Boolean
-
#to_cookie ⇒ Object
Returns session id represented as cookie in order to append it to response.
-
#to_s ⇒ Object
Returns string representation of the receiver.
Instance Attribute Details
#last_access_time ⇒ Object
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 |
#sid ⇒ Object (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 |
.sessions ⇒ Object
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
81 82 83 |
# File 'lib/sws/session.rb', line 81 def old? ( component_id ) return @component_cache.old?( component_id ) end |
#to_cookie ⇒ Object
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 () return Cookie.new( "session",@sid ) end |
#to_s ⇒ Object
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 |