Class: Flash

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

Instance Method Summary collapse

Constructor Details

#initialize(req) ⇒ Flash

Returns a new instance of Flash.



2
3
4
5
6
7
8
# File 'lib/actioncondor/flash.rb', line 2

def initialize(req)
  @flash = {}

  app_cookie = req.cookies['_gazebo_app_flash']

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

Instance Method Details

#[](key) ⇒ Object



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

def [](key)
  @flash[key.to_s] || @flash_now[key.to_s] || @flash_now[key]
end

#[]=(key, val) ⇒ Object



18
19
20
# File 'lib/actioncondor/flash.rb', line 18

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

#nowObject



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

def now
  @flash_now
end

#store_flash(res) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/actioncondor/flash.rb', line 22

def store_flash(res)
  res.set_cookie(
    '_gazebo_app_flash',
    path: '/',
    value: @flash.to_json
  )
end