Class: KStor::Session
- Inherits:
-
Object
- Object
- KStor::Session
- Defined in:
- lib/kstor/session.rb
Overview
A user session in memory.
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#secret_key ⇒ Object
readonly
Returns the value of attribute secret_key.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
-
.create(user, secret_key) ⇒ KStor::Session
Create a new session for a user.
Instance Method Summary collapse
-
#initialize(sid, user, secret_key) ⇒ KStor::Session
constructor
Create a new user session.
-
#update ⇒ KStor::Session
Update access time, for idle sessions weeding.
Constructor Details
#initialize(sid, user, secret_key) ⇒ KStor::Session
Create a new user session.
21 22 23 24 25 26 27 |
# File 'lib/kstor/session.rb', line 21 def initialize(sid, user, secret_key) @id = sid @user = user @secret_key = secret_key @created_at = Time.now @updated_at = Time.now end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
11 12 13 |
# File 'lib/kstor/session.rb', line 11 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/kstor/session.rb', line 8 def id @id end |
#secret_key ⇒ Object (readonly)
Returns the value of attribute secret_key.
10 11 12 |
# File 'lib/kstor/session.rb', line 10 def secret_key @secret_key end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
12 13 14 |
# File 'lib/kstor/session.rb', line 12 def updated_at @updated_at end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
9 10 11 |
# File 'lib/kstor/session.rb', line 9 def user @user end |
Class Method Details
.create(user, secret_key) ⇒ KStor::Session
Create a new session for a user.
43 44 45 46 |
# File 'lib/kstor/session.rb', line 43 def self.create(user, secret_key) sid = SecureRandom.urlsafe_base64(16) new(sid, user, secret_key) end |
Instance Method Details
#update ⇒ KStor::Session
Update access time, for idle sessions weeding.
32 33 34 35 |
# File 'lib/kstor/session.rb', line 32 def update @updated_at = Time.now self end |