Class: WhalesDispatch::Flash
- Inherits:
-
Object
- Object
- WhalesDispatch::Flash
- Defined in:
- lib/whales_dispatch/flash.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(request) ⇒ Flash
constructor
A new instance of Flash.
- #now ⇒ Object
- #store_flash(response) ⇒ Object
Constructor Details
#initialize(request) ⇒ Flash
Returns a new instance of Flash.
7 8 9 10 11 12 13 |
# File 'lib/whales_dispatch/flash.rb', line 7 def initialize(request) request..each do || @value_for_now = JSON.parse(.value) if .name == '_whales_flash' end @value_for_now ||= {} @value_for_next = {} end |
Instance Method Details
#[](key) ⇒ Object
19 20 21 22 |
# File 'lib/whales_dispatch/flash.rb', line 19 def [](key) combined = @value_for_next.merge(@value_for_now) combined[key.to_s] || combined[key.to_sym] end |
#[]=(key, value) ⇒ Object
24 25 26 |
# File 'lib/whales_dispatch/flash.rb', line 24 def []=(key, value) @value_for_next[key] = value end |
#now ⇒ Object
15 16 17 |
# File 'lib/whales_dispatch/flash.rb', line 15 def now @value_for_now end |
#store_flash(response) ⇒ Object
28 29 30 31 32 |
# File 'lib/whales_dispatch/flash.rb', line 28 def store_flash(response) = WEBrick::Cookie.new('_whales_flash', @value_for_next.to_json) .path = '/' response. << end |