Class: Session

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(req) ⇒ Session

Returns a new instance of Session.



4
5
6
7
8
# File 'lib/actioncondor/session.rb', line 4

def initialize(req)
  app_cookie = req.cookies['_gazebo_app']

  @cookie = app_cookie ? JSON.parse(app_cookie) : {}
end

Instance Attribute Details

Returns the value of attribute cookie.



2
3
4
# File 'lib/actioncondor/session.rb', line 2

def cookie
  @cookie
end

Instance Method Details

#[](key) ⇒ Object



10
11
12
# File 'lib/actioncondor/session.rb', line 10

def [](key)
  @cookie[key.to_s]
end

#[]=(key, val) ⇒ Object



14
15
16
# File 'lib/actioncondor/session.rb', line 14

def []=(key, val)
  @cookie[key.to_s] = val
end

#store_session(res) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/actioncondor/session.rb', line 18

def store_session(res)
  res.set_cookie(
    '_gazebo_app',
    path: '/',
    value: @cookie.to_json
  )
end