Class: Flash
- Inherits:
-
Object
- Object
- Flash
- Defined in:
- lib/railz_lite/controllers/flash.rb
Instance Attribute Summary collapse
-
#now ⇒ Object
readonly
Returns the value of attribute now.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, val) ⇒ 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 |
# File 'lib/railz_lite/controllers/flash.rb', line 5 def initialize(req) = req.['_rails_lite_app_flash'] @now = !.nil? ? JSON.parse() : {} @flash = {} end |
Instance Attribute Details
#now ⇒ Object (readonly)
Returns the value of attribute now.
4 5 6 |
# File 'lib/railz_lite/controllers/flash.rb', line 4 def now @now end |
Instance Method Details
#[](key) ⇒ Object
11 12 13 |
# File 'lib/railz_lite/controllers/flash.rb', line 11 def [](key) @now[key.to_s] || @flash[key.to_s] end |
#[]=(key, val) ⇒ Object
15 16 17 |
# File 'lib/railz_lite/controllers/flash.rb', line 15 def []=(key, val) @flash[key] = val end |
#store_flash(res) ⇒ Object
19 20 21 |
# File 'lib/railz_lite/controllers/flash.rb', line 19 def store_flash(res) res.('_rails_lite_app_flash', value: @flash.to_json, path: '/') end |