Class: Volt::Persistors::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/volt/models/persistors/base.rb
Overview
Implements the base persistor functionality.
Instance Method Summary
collapse
Instance Method Details
#added(model, index) ⇒ Object
12
13
|
# File 'lib/volt/models/persistors/base.rb', line 12
def added(model, index)
end
|
#changed(attribute_name) ⇒ Object
9
10
|
# File 'lib/volt/models/persistors/base.rb', line 9
def changed(attribute_name)
end
|
Called when the model is cleared (all child models removed)
21
22
|
# File 'lib/volt/models/persistors/base.rb', line 21
def clear
end
|
#event_added(event, first, first_for_event) ⇒ Object
24
25
|
# File 'lib/volt/models/persistors/base.rb', line 24
def event_added(event, first, first_for_event)
end
|
#event_removed(event, last, last_for_event) ⇒ Object
27
28
|
# File 'lib/volt/models/persistors/base.rb', line 27
def event_removed(event, last, last_for_event)
end
|
#loaded(initial_state = nil) ⇒ Object
5
6
7
|
# File 'lib/volt/models/persistors/base.rb', line 5
def loaded(initial_state = nil)
@model.change_state_to(:loaded_state, initial_state || :loaded)
end
|
#removed(attribute_name) ⇒ Object
For removed, the default action is to call changed for it
16
17
18
|
# File 'lib/volt/models/persistors/base.rb', line 16
def removed(attribute_name)
changed(attribute_name)
end
|
#root_model ⇒ Object
Find the root for this model
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/volt/models/persistors/base.rb', line 31
def root_model
node = @model
loop do
parent = node.parent
if parent
node = parent
else
break
end
end
node
end
|