Class: Tzispa::Helpers::Session::SessionFlashBag

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/tzispa/helpers/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/helpers/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
# File 'lib/tzispa/helpers/session_flash_bag.rb', line 23

def <<(value)
  return unless value
  bag << value
  store
end

#popObject



29
30
31
32
33
# File 'lib/tzispa/helpers/session_flash_bag.rb', line 29

def pop
  value = bag.pop
  store
  value
end

#pop_allObject



35
36
37
38
# File 'lib/tzispa/helpers/session_flash_bag.rb', line 35

def pop_all
  empty!
  bag
end

#push(value) ⇒ Object



40
41
42
43
# File 'lib/tzispa/helpers/session_flash_bag.rb', line 40

def push(value)
  bag.push value
  store
end