Class: KStor::Session

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

Overview

A user session in memory.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_atObject (readonly)

Returns the value of attribute created_at.



11
12
13
# File 'lib/kstor/session.rb', line 11

def created_at
  @created_at
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/kstor/session.rb', line 8

def id
  @id
end

#secret_keyObject (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_atObject (readonly)

Returns the value of attribute updated_at.



12
13
14
# File 'lib/kstor/session.rb', line 12

def updated_at
  @updated_at
end

#userObject (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

#updateObject



22
23
24
25
# File 'lib/kstor/session.rb', line 22

def update
  @updated_at = Time.now
  self
end