Permalink
Browse files

-- renamed the orphan strategy

  • Loading branch information...
1 parent a57de86 commit 94dba1c18a3a6906013263374cb274c038b22ba3 unknown committed Jun 25, 2012
Showing with 7 additions and 7 deletions.
  1. +3 −3 lib/ancestry/class_methods.rb
  2. +2 −2 lib/ancestry/instance_methods.rb
  3. +2 −2 test/has_ancestry_test.rb
@@ -19,11 +19,11 @@ def scope_depth depth_options, depth
# Orphan strategy writer
def orphan_strategy= orphan_strategy
- # Check value of orphan strategy, only rootify, parentify, restrict or destroy is allowed
- if [:rootify, :parentify, :restrict, :destroy].include? orphan_strategy
+ # Check value of orphan strategy, only rootify, adopt, restrict or destroy is allowed
+ if [:rootify, :adopt, :restrict, :destroy].include? orphan_strategy
class_variable_set :@@orphan_strategy, orphan_strategy
else
- raise Ancestry::AncestryException.new("Invalid orphan strategy, valid ones are :rootify,:parentify, :restrict and :destroy.")
+ raise Ancestry::AncestryException.new("Invalid orphan strategy, valid ones are :rootify,:adopt, :restrict and :destroy.")
end
end
@@ -48,8 +48,8 @@ def apply_orphan_strategy
descendant.destroy
end
end
- # ... make child elements of this node, child of its parent if orphan strategy is parentify
- elsif self.base_class.orphan_strategy == :parentify
+ # ... make child elements of this node, child of its parent if orphan strategy is adopt
+ elsif self.base_class.orphan_strategy == :adopt
descendants.all.each do |descendant|
descendant.without_ancestry_callbacks do
new_ancestry = descendant.ancestor_ids.delete_if { |x| x == self.id }.join("/")
@@ -324,9 +324,9 @@ def test_orphan_restrict_strategy
end
end
- def test_orphan_parentify_strategy
+ def test_orphan_adopt_strategy
AncestryTestDatabase.with_model do |model|
- model.orphan_strategy = :parentify # set the orphan strategy as paerntify
+ model.orphan_strategy = :adopt # set the orphan strategy as paerntify
n1 = model.create! #create a root node
n2 = model.create!(:parent => n1) #create child with parent=root
n3 = model.create!(:parent => n2) #create child with parent=n2, depth = 2

0 comments on commit 94dba1c

Please sign in to comment.