Class: Flash

Inherits:
Object
  • Object
show all
Defined in:
lib/yodel/request/flash.rb

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ Flash

Returns a new instance of Flash.



2
3
4
5
6
# File 'lib/yodel/request/flash.rb', line 2

def initialize(session)
  @session = session
  @last_request = @session['flash'] || {}
  @this_request = {}
end

Instance Method Details

#[](key) ⇒ Object



12
13
14
# File 'lib/yodel/request/flash.rb', line 12

def [](key)
  @this_request[key] || @last_request[key]
end

#[]=(key, value) ⇒ Object



20
21
22
# File 'lib/yodel/request/flash.rb', line 20

def []=(key, value)
  @this_request[key] = value
end

#delete(key) ⇒ Object



24
25
26
27
# File 'lib/yodel/request/flash.rb', line 24

def delete(key)
  @this_request.delete(key)
  @last_request.delete(key)
end

#finalizeObject



8
9
10
# File 'lib/yodel/request/flash.rb', line 8

def finalize
  @session['flash'] = @this_request
end

#now(key, value) ⇒ Object



16
17
18
# File 'lib/yodel/request/flash.rb', line 16

def now(key, value)
  @last_request[key] = value
end