Permalink
Browse files

removed deprecated method

  • Loading branch information...
bkeepers committed Aug 22, 2008
1 parent e466d33 commit 75506328b0ebb581d7cbc34bd19bcb1fc778fe7f
Showing with 0 additions and 42 deletions.
  1. +0 −42 lib/awesome_nested_set.rb
View
@@ -262,48 +262,6 @@ def <=>(x)
left <=> x.left
end
- # Adds a child to this object in the tree. If this object hasn't been initialized,
- # it gets set up as a root node. Otherwise, this method will update all of the
- # other elements in the tree and shift them to the right, keeping everything
- # balanced.
- #
- # Deprecated, will be removed in next versions
- def add_child( child )
- self.reload
- child.reload
-
- if child.root?
- raise ActiveRecord::ActiveRecordError, "Adding sub-tree isn\'t currently supported"
- else
- if ( (self[left_column_name] == nil) || (right == nil) )
- # Looks like we're now the root node! Woo
- self[left_column_name] = 1
- self[right_column_name] = 4
-
- # What do to do about validation?
- return nil unless self.save
-
- child[parent_column_name] = self.id
- child[left_column_name] = 2
- child[right_column_name]= 3
- return child.save
- else
- # OK, we need to add and shift everything else to the right
- child[parent_column_name] = self.id
- right_bound = right
- child[left_column_name] = right_bound
- child[right_column_name] = right_bound + 1
- self[right_column_name] += 2
- self.class.base_class.transaction {
- self.class.base_class.update_all( "#{left_column_name} = (#{left_column_name} + 2)", "#{acts_as_nested_set_options[:scope]} AND #{left_column_name} >= #{right_bound}" )
- self.class.base_class.update_all( "#{right_column_name} = (#{right_column_name} + 2)", "#{acts_as_nested_set_options[:scope]} AND #{right_column_name} >= #{right_bound}" )
- self.save
- child.save
- }
- end
- end
- end
-
# Returns root
def root
self_and_ancestors.find(:first)

0 comments on commit 7550632

Please sign in to comment.