class Volt::Persistors::Base
Implements the base persistor functionality.
Public Class Methods
new(model)
click to toggle source
# File lib/volt/models/persistors/base.rb, line 5 def initialize(model) @model = model end
Public Instance Methods
added(model, index)
click to toggle source
# File lib/volt/models/persistors/base.rb, line 20 def added(model, index) end
async?()
click to toggle source
return true if this persistor is asynchronus and needs to return Promises.
# File lib/volt/models/persistors/base.rb, line 45 def async? false end
auto_generate_id()
click to toggle source
Specify if this collection should auto-generate id's
# File lib/volt/models/persistors/base.rb, line 39 def auto_generate_id false end
changed(attribute_name)
click to toggle source
Method that is called when data on the model changes. @returns [true|Promise] - should return a Promise
or true. On async
persistors, the promise from set and save! will wait on the Promise.
# File lib/volt/models/persistors/base.rb, line 17 def changed(attribute_name) end
clear()
click to toggle source
Called when the model is cleared (all child models removed)
# File lib/volt/models/persistors/base.rb, line 29 def clear end
event_added(event, first, first_for_event)
click to toggle source
# File lib/volt/models/persistors/base.rb, line 32 def event_added(event, first, first_for_event) end
event_removed(event, last, last_for_event)
click to toggle source
# File lib/volt/models/persistors/base.rb, line 35 def event_removed(event, last, last_for_event) end
loaded(initial_state = nil)
click to toggle source
# File lib/volt/models/persistors/base.rb, line 9 def loaded(initial_state = nil) @model.change_state_to(:loaded_state, initial_state || :loaded) end
removed(attribute_name)
click to toggle source
For removed, the default action is to call changed for it
# File lib/volt/models/persistors/base.rb, line 24 def removed(attribute_name) changed(attribute_name) end
root_model()
click to toggle source
Find the root for this model
# File lib/volt/models/persistors/base.rb, line 50 def root_model node = @model loop do parent = node.parent if parent node = parent else break end end node end