Class: Flash
- Inherits:
-
Object
- Object
- Flash
- Defined in:
- lib/flash.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(req) ⇒ Flash
constructor
A new instance of Flash.
- #store_flash(res) ⇒ Object
Constructor Details
#initialize(req) ⇒ Flash
Returns a new instance of Flash.
5 6 7 8 9 10 |
# File 'lib/flash.rb', line 5 def initialize(req) = req.['flash'] @now = ? JSON.parse() : {} @flash = {} end |
Instance Method Details
#[](key) ⇒ Object
16 17 18 |
# File 'lib/flash.rb', line 16 def [](key) @now[key.to_s] || @flash[key.to_s] end |
#[]=(key, value) ⇒ Object
20 21 22 |
# File 'lib/flash.rb', line 20 def []=(key, value) @flash[key.to_s] = value end |
#store_flash(res) ⇒ Object
12 13 14 |
# File 'lib/flash.rb', line 12 def store_flash(res) res.('flash', { path: '/', value: @flash.to_json }) end |