Skip to content

Commit

Permalink
add ancestry case to the genealogy parent setter
Browse files Browse the repository at this point in the history
when we destroy all relationships, we'll want to alias
this setter to parent=
  • Loading branch information
d-m-u committed Nov 5, 2020
1 parent 9cd54e7 commit 528509b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/models/vm_or_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,19 @@ def genealogy_parent
end

def genealogy_parent=(parent)
@genealogy_parent_object = parent
with_relationship_type('genealogy') do
if use_ancestry?
self.parent = parent
else
@genealogy_parent_object = parent
end
end
end

# save_genealogy_information is only necessary for relationships using genealogy
# when using ancestry, the relationship will be saved after the fact
# when not using ancestry, the relationship is saved on assignment, necessitating the prior save of the vm/template record
# this variable is used to delay that assignment
def save_genealogy_information
if defined?(@genealogy_parent_object) && @genealogy_parent_object
with_relationship_type('genealogy') { self.parent = @genealogy_parent_object }
Expand Down

0 comments on commit 528509b

Please sign in to comment.