Module: Tree::Utils::TreeMergeHandler
- Included in:
- TreeNode
- Defined in:
- lib/tree/utils/tree_merge_handler.rb
Overview
Handles merging of two trees.
Merging Trees collapse
-
#merge(other_tree) ⇒ Tree::TreeNode
Merge two trees that share the same root node and returns a new tree.
-
#merge!(other_tree) ⇒ Object
Merge in another tree (that shares the same root node) into
this
tree.
Instance Method Details
#merge(other_tree) ⇒ Tree::TreeNode
Merge two trees that share the same root node and returns a new tree.
The new tree contains the contents of the merge between other_tree and self. Duplicate nodes (coming from other_tree) will NOT be overwritten in self.
64 65 66 67 |
# File 'lib/tree/utils/tree_merge_handler.rb', line 64 def merge(other_tree) check_merge_prerequisites(other_tree) merge_trees(root.dup, other_tree.root) end |
#merge!(other_tree) ⇒ Object
Merge in another tree (that shares the same root node) into this
tree. Duplicate nodes (coming from other_tree) will NOT be overwritten in self.
82 83 84 85 |
# File 'lib/tree/utils/tree_merge_handler.rb', line 82 def merge!(other_tree) check_merge_prerequisites(other_tree) merge_trees(root, other_tree.root) end |