lib/webgen/tree.rb in gettalong-webgen-0.5.5.20081001 vs lib/webgen/tree.rb in gettalong-webgen-0.5.5.20081010

- old
+ new

@@ -49,23 +49,27 @@ raise "Can't have two nodes with same absolute lcn: #{node.absolute_lcn}" else @node_access[:alcn][node.absolute_lcn] = node end (@node_access[:acn][node.absolute_cn] ||= []) << node + register_path(node) + end + + # A utility method called by Node#reinit. This method should not be used directly! + def register_path(node) if @node_access[:path].has_key?(node.path) raise "Can't have two nodes with same output path: #{node.path}" unless node['no_output'] else @node_access[:path][node.path] = node end end - # Delete the node identified by +node_or_alcn+ and all of its children from the - # tree. Directories are only deleted if +delete_dir+ is +true+. - def delete_node(node_or_alcn, delete_dir = false) + # Delete the node identified by +node_or_alcn+ and all of its children from the tree. + def delete_node(node_or_alcn) n = node_or_alcn.kind_of?(Node) ? node_or_alcn : @node_access[:alcn][node_or_alcn] - return if n.nil? || n == @dummy_root || (n.is_directory? && !delete_dir) + return if n.nil? || n == @dummy_root - n.children.dup.each {|child| delete_node(child, delete_dir)} + n.children.dup.each {|child| delete_node(child)} website.blackboard.dispatch_msg(:before_node_deleted, n) n.parent.children.delete(n) @node_access[:alcn].delete(n.absolute_lcn) @node_access[:acn][n.absolute_cn].delete(n)