Class: Flash
Instance Attribute Summary collapse
-
#fresh_cookie ⇒ Object
readonly
Returns the value of attribute fresh_cookie.
-
#stale_cookie ⇒ Object
readonly
Returns the value of attribute stale_cookie.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, val) ⇒ Object
-
#initialize(req) ⇒ Flash
constructor
A new instance of Flash.
- #now ⇒ Object
- #persistent? ⇒ Boolean
- #store_flash(res) ⇒ Object
Constructor Details
#initialize(req) ⇒ Flash
Returns a new instance of Flash.
4 5 6 7 8 9 |
# File 'lib/laris/controller/flash.rb', line 4 def initialize(req) = req.['_laris_flash'] @stale_cookie = ? JSON.parse() : {} @fresh_cookie = {} @persistent = true end |
Instance Attribute Details
#fresh_cookie ⇒ Object (readonly)
Returns the value of attribute fresh_cookie.
2 3 4 |
# File 'lib/laris/controller/flash.rb', line 2 def @fresh_cookie end |
#stale_cookie ⇒ Object (readonly)
Returns the value of attribute stale_cookie.
2 3 4 |
# File 'lib/laris/controller/flash.rb', line 2 def @stale_cookie end |
Instance Method Details
#[](key) ⇒ Object
20 21 22 |
# File 'lib/laris/controller/flash.rb', line 20 def [](key) .merge()[key] end |
#[]=(key, val) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/laris/controller/flash.rb', line 24 def []=(key, val) if persistent? [key] = val else [key] = val end @persistent = true val end |
#now ⇒ Object
15 16 17 18 |
# File 'lib/laris/controller/flash.rb', line 15 def now @persistent = false self end |
#persistent? ⇒ Boolean
11 12 13 |
# File 'lib/laris/controller/flash.rb', line 11 def persistent? @persistent end |
#store_flash(res) ⇒ Object
35 36 37 38 |
# File 'lib/laris/controller/flash.rb', line 35 def store_flash(res) = { path: '/', value: .to_json } res.('_laris_flash', ) end |