# File lib/dm-is-nested_set/is/nested_set.rb, line 62 def adjust_gap!(scoped_set,at,adjustment) scoped_set.all(:rgt.gt => at).adjust!({ :rgt => adjustment }, true) scoped_set.all(:lft.gt => at).adjust!({ :lft => adjustment }, true) end
# File lib/dm-is-nested_set/is/nested_set.rb, line 90 def leaves # TODO scoping, how should it act? # TODO supply filtering-option? all(:conditions => [ 'rgt = lft + ?', 1 ], :order => [ :lft ]) end
rebuilds the nested set using parent/child relationships and a chosen order
# File lib/dm-is-nested_set/is/nested_set.rb, line 109 def rebuild_set_from_tree(order = nil) # TODO pending end
rebuilds the parent/child relationships (parent_id) from nested set (left/right values)
# File lib/dm-is-nested_set/is/nested_set.rb, line 99 def rebuild_tree_from_set all.each do |node| node.parent = node.ancestor node.save end end
get the root of the tree. if sets are scoped, this will return false
# File lib/dm-is-nested_set/is/nested_set.rb, line 70 def root # TODO scoping # what should this return if there is a scope? always false, or node if there is only one? args = Hash[ nested_set_parent.zip([]) ] roots.length > 1 ? false : first(args) end
Generated with the Darkfish Rdoc Generator 2.