Module: Xampl::XamplPersistedObject
Instance Attribute Summary collapse
Attributes included from XamplObject
#is_changed, #parents
Instance Method Summary
collapse
#===, #add_parent, #changes_accepted, #compare_xampl, #copy_xampl, #dirty?, from_ruby, from_string, from_xml_file, from_xml_string, #ignore_when_no_index, #indexed_by, #init_attributes, #init_hook, #inspect, #invalid, #invalidate, lookup_preferred_ns_prefix, #mark_changed_deep, #new_from_xml_file, #new_from_xml_string, #note_add_child, #note_add_to_parent, #note_adding_text_content, #note_attributes_initialised, #note_closed, #note_created, #note_initialise_attributes_with, #note_invalidate, #note_realised, #note_replacing, ns_preferred_prefix, #persist, #pp_xml, realise_from_xml_string, recover_from_string, #remove_ws_content, #schedule_a_deletion_if_needed, #should_schedule_delete?, #substituting_to_xml, #to_ruby, #to_s, #to_xml
Instance Attribute Details
#load_needed ⇒ Object
Returns the value of attribute load_needed.
7
8
9
|
# File 'lib/xamplr/xampl-persisted-object.rb', line 7
def load_needed
@load_needed
end
|
#must_be_mentioned ⇒ Object
Returns the value of attribute must_be_mentioned.
8
9
10
|
# File 'lib/xamplr/xampl-persisted-object.rb', line 8
def must_be_mentioned
@must_be_mentioned
end
|
#persister ⇒ Object
Returns the value of attribute persister.
6
7
8
|
# File 'lib/xamplr/xampl-persisted-object.rb', line 6
def persister
@persister
end
|
Instance Method Details
#accessed ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/xamplr/xampl-persisted-object.rb', line 14
def accessed
raise XamplIsInvalid.new(self) if invalid return unless @load_needed
raise NoActivePersister.new unless @persister
raise XamplException(:load_blocked_because_persister_is_syncing,
"often happens when you are describing a xampl object using a different persisted xampl object that hasn't been loaded yet") if @persister.syncing
Xampl.read_only(@persister) do
Xampl.lazy_load(self)
end
end
|
#changed ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/xamplr/xampl-persisted-object.rb', line 32
def changed
raise UnmanagedChange.new(self) unless Xampl.persister
if @persister then
raise UnmanagedChange.new(self) if Xampl.persister != @persister
raise BlockedChange.new(self) if @persister.block_changes
end
unless @is_changed then
@is_changed = true
if @persister then
@persister.has_changed self
end
end
end
|
#changed? ⇒ Boolean
28
29
30
|
# File 'lib/xamplr/xampl-persisted-object.rb', line 28
def changed?
@is_changed = true
end
|
#describe_yourself ⇒ Object
88
89
90
|
# File 'lib/xamplr/xampl-persisted-object.rb', line 88
def describe_yourself
nil
end
|
#force_load ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/xamplr/xampl-persisted-object.rb', line 48
def force_load
@load_needed = true
@is_changed = false
@persister.has_not_changed(self) if @persister
self.clear_non_persistent_index_attributes
methods = self.methods.grep(/init_.*_as_child/)
methods.each do |method_name|
self.send(method_name)
end
@children = []
end
|
#init_xampl_object ⇒ Object
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/xamplr/xampl-persisted-object.rb', line 77
def init_xampl_object
super
@persister = nil
@load_needed = false
if (Xampl.persister and Xampl.persister.automatic) then
Xampl.persister.introduce(self)
else
introduce_persister(nil)
end
end
|
#introduce_persister(persister) ⇒ Object
#persist_required ⇒ Object
10
11
12
|
# File 'lib/xamplr/xampl-persisted-object.rb', line 10
def persist_required
return true
end
|
#reset_contents ⇒ Object
60
61
62
63
64
65
66
|
# File 'lib/xamplr/xampl-persisted-object.rb', line 60
def reset_contents
self.clear_non_persistent_index_attributes
self.methods.grep(/init_.*_as_child/).each do |method_name|
self.send(method_name)
end
@children = []
end
|