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 Oct 2, 2020
1 parent b4f85bd commit 7750cd9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/models/vm_or_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,17 @@ 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

# only necessary for relationships using genealogy
# delete when using ancestry
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 7750cd9

Please sign in to comment.