Class: Flash
- Inherits:
-
Object
- Object
- Flash
- Defined in:
- lib/flash.rb
Instance Attribute Summary collapse
-
#later ⇒ Object
readonly
Returns the value of attribute later.
-
#now ⇒ Object
readonly
Returns the value of attribute now.
Instance Method Summary collapse
- #[](message_type) ⇒ Object
- #[]=(message_type, 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.
4 5 6 7 8 9 |
# File 'lib/flash.rb', line 4 def initialize(req) = req.["_trails_flash"] @now = JSON.parse() if @now ||= {} @later = {} end |
Instance Attribute Details
#later ⇒ Object (readonly)
Returns the value of attribute later.
2 3 4 |
# File 'lib/flash.rb', line 2 def later @later end |
#now ⇒ Object (readonly)
Returns the value of attribute now.
2 3 4 |
# File 'lib/flash.rb', line 2 def now @now end |
Instance Method Details
#[](message_type) ⇒ Object
11 12 13 |
# File 'lib/flash.rb', line 11 def []() now[] end |
#[]=(message_type, value) ⇒ Object
15 16 17 |
# File 'lib/flash.rb', line 15 def []=(, value) later[] = value end |
#store_flash(res) ⇒ Object
19 20 21 22 23 |
# File 'lib/flash.rb', line 19 def store_flash(res) self[:path] = "/" self[:value] = later.to_json res.("_trails_flash", later) end |