Class: Session

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

Instance Method Summary collapse

Constructor Details

#initialize(req) ⇒ Session

Returns a new instance of Session.

[View source]

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

def initialize(req)
  if req.cookies['_']
    @cookie =  JSON.parse(req.cookies['_bezel'])
  else
    @cookie = {}
  end
end

Instance Method Details

#[](key) ⇒ Object

[View source]

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

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

#[]=(key, val) ⇒ Object

[View source]

16
17
18
# File 'lib/session.rb', line 16

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

#store_session(res) ⇒ Object

[View source]

20
21
22
23
# File 'lib/session.rb', line 20

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