Class: Tzispa::Http::SessionFlashBag

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/tzispa/http/session_flash_bag.rb

Constant Summary collapse

SESSION_FLASH_BAG =
:__flash_bag

Instance Method Summary collapse

Constructor Details

#initialize(session, key) ⇒ SessionFlashBag

Returns a new instance of SessionFlashBag.



17
18
19
20
21
# File 'lib/tzispa/http/session_flash_bag.rb', line 17

def initialize(session, key)
  @session = session
  @session_key = "#{SESSION_FLASH_BAG}_#{key}".to_sym
  load!
end

Instance Method Details

#<<(value) ⇒ Object



23
24
25
26
27
28
# File 'lib/tzispa/http/session_flash_bag.rb', line 23

def << (value)
  if not value.nil?
    @bag << value
    store
  end
end

#popObject



30
31
32
33
34
# File 'lib/tzispa/http/session_flash_bag.rb', line 30

def pop
  value = @bag.pop
  store
  value
end

#pop_allObject



36
37
38
39
# File 'lib/tzispa/http/session_flash_bag.rb', line 36

def pop_all
  empty!
  @bag
end

#push(value) ⇒ Object



41
42
43
44
# File 'lib/tzispa/http/session_flash_bag.rb', line 41

def push(value)
  @bag.push value
  store
end