engines/adva_cms/vendor/plugins/simple_nested_set/lib/simple_nested_set.rb
# Prunes a branch off of the tree, shifting all of the elements on the right
# back to the left so the counts still work.
Prunes a branch off of the tree, shifting all of the elements on the right
back to the left so the counts still work.
Prunes a branch off of the tree shifting all of the elements on the right back to the left so the counts still work .
def prune_branch
          return if rgt.nil? || lft.nil?
          diff = rgt - lft + 1
          self.class.transaction {
            nested_set.delete_all "lft > #{lft} AND rgt < #{rgt}"
            nested_set.update_all "lft = (lft - #{diff})",   "lft >= #{rgt}"
            nested_set.update_all "rgt = (rgt - #{diff} )",  "rgt >= #{rgt}"
          }
        end
def prune_branch return if rgt . nil? || lft . nil? diff = rgt - lft + 1 self . class . transaction { nested_set . delete_all "lft > #{lft} AND rgt < #{rgt}" nested_set . update_all "lft = (lft - #{diff})" , "lft >= #{rgt}" nested_set . update_all "rgt = (rgt - #{diff} )" , "rgt >= #{rgt}" } end
Prunes a branch off of the tree, shifting all of the elements on the right
back to the left so the counts still work.
Prunes a branch off of the tree shifting all of the elements on the right back to the left so the counts still work .