Class: Volt::Persistors::Flash
- Defined in:
- lib/volt/models/persistors/flash.rb
Instance Method Summary collapse
- #added(model, index) ⇒ Object
- #clear_model(model) ⇒ Object
-
#initialize(model) ⇒ Flash
constructor
A new instance of Flash.
Methods inherited from Base
#changed, #clear, #event_added, #event_removed, #loaded, #removed, #root_model
Constructor Details
#initialize(model) ⇒ Flash
Returns a new instance of Flash.
6 7 8 |
# File 'lib/volt/models/persistors/flash.rb', line 6 def initialize(model) @model = model end |
Instance Method Details
#added(model, index) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/volt/models/persistors/flash.rb', line 10 def added(model, index) if Volt.client? # Setup a new timer for clearing the flash. ` setTimeout(function() { self.$clear_model(model); }, 5000); ` end # Need to return nil to prevent non-opal object return nil end |
#clear_model(model) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/volt/models/persistors/flash.rb', line 24 def clear_model(model) @model.delete(model) # Clear out the parent collection (usually the main flash) # Makes it so flash.empty? reflects if there is any outstanding # flashes. if @model.size == 0 collection_name = @model.path[-1] @model.parent.delete(collection_name) end end |