Class: Bezel::Flash
- Inherits:
-
Object
- Object
- Bezel::Flash
- Defined in:
- lib/flash.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, val) ⇒ Object
-
#initialize(req) ⇒ Flash
constructor
A new instance of Flash.
- #now ⇒ Object
- #store_flash(res) ⇒ Object
Constructor Details
#initialize(req) ⇒ Flash
Returns a new instance of Flash.
4 5 6 7 8 9 10 11 |
# File 'lib/flash.rb', line 4 def initialize(req) if req.['_bezel_flash'] @flash = JSON.parse(req.['_bezel_flash']) else @flash = {} end @flash_now = {} end |
Instance Method Details
#[](key) ⇒ Object
17 18 19 20 |
# File 'lib/flash.rb', line 17 def [](key) return @flash_now[key] if @flash_now[key] @flash[key.to_s] end |
#[]=(key, val) ⇒ Object
13 14 15 |
# File 'lib/flash.rb', line 13 def []=(key,val) @flash[key] = val end |
#now ⇒ Object
26 27 28 |
# File 'lib/flash.rb', line 26 def now @flash_now end |
#store_flash(res) ⇒ Object
22 23 24 |
# File 'lib/flash.rb', line 22 def store_flash(res) res.('_bezel_flash', value: @flash.to_json, path: '/') end |