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
Instance Method Summary collapse
-
#initialize(sid, user, secret_key) ⇒ Session
constructor
A new instance of Session.
- #update ⇒ Object
Constructor Details
#initialize(sid, user, secret_key) ⇒ Session
Returns a new instance of Session.
14 15 16 17 18 19 20 |
# File 'lib/kstor/session.rb', line 14 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) ⇒ Object
27 28 29 30 |
# File 'lib/kstor/session.rb', line 27 def self.create(user, secret_key) sid = SecureRandom.urlsafe_base64(16) new(sid, user, secret_key) end |
Instance Method Details
#update ⇒ Object
22 23 24 25 |
# File 'lib/kstor/session.rb', line 22 def update @updated_at = Time.now self end |