You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -346,22 +346,27 @@ When you include ```has_closure_tree``` in your model, you can provide a hash to
346
346
347
347
* ```tag.root``` returns the root for this node
348
348
* ```tag.root?``` returns true if this is a root node
349
+
* ```tag.root_of?(node)``` returns true if current node is root of another one
349
350
* ```tag.child?``` returns true if this is a child node. It has a parent.
350
351
* ```tag.leaf?``` returns true if this is a leaf node. It has no children.
351
352
* ```tag.leaves``` is scoped to all leaf nodes in self_and_descendants.
352
353
* ```tag.depth``` returns the depth, or "generation", for this node in the tree. A root node will have a value of 0.
353
354
* ```tag.parent``` returns the node's immediate parent. Root nodes will returnnil.
355
+
*```tag.parent_of?(node)``` returns trueif current node is parent of another one
354
356
*```tag.children``` is a ```has_many``` of immediate children (just those nodes whose parent is the current node).
355
357
*```tag.child_ids``` is an array of the IDs of the children.
358
+
*```tag.child_of?(node)``` returns trueif current node is child of another one
356
359
*```tag.ancestors``` is a ordered scope of [ parent, grandparent, great grandparent, … ]. Note that the size of this array will always equal ```tag.depth```.
357
360
*```tag.ancestor_ids``` is an array of the IDs of the ancestors.
361
+
*```tag.ancestor_of?(node)``` returns trueif current node is ancestor of another one
358
362
*```tag.self_and_ancestors``` returns a scope containing self, parent, grandparent, great grandparent, etc.
359
363
*```tag.self_and_ancestors_ids``` returns IDs containing self, parent, grandparent, great grandparent, etc.
360
364
*```tag.siblings``` returns a scope containing all nodes with the same parent as ```tag```, excluding self.
361
365
*```tag.sibling_ids``` returns an array of the IDs of the siblings.
362
366
*```tag.self_and_siblings``` returns a scope containing all nodes with the same parent as ```tag```, including self.
363
367
*```tag.descendants``` returns a scope of all children, childrens' children, etc., excluding self ordered by depth.
364
368
* ```tag.descendant_ids``` returns an array of the IDs of the descendants.
369
+
* ```tag.descendant_of?(node)``` returns true if current node is descendant of another one
365
370
* ```tag.self_and_descendants``` returns a scope of self, all children, childrens' children, etc., ordered by depth.
366
371
*```tag.self_and_descendant_ids``` returns IDs of self, all children, childrens' children, etc., ordered by depth.
367
372
* ```tag.hash_tree``` returns an [ordered, nested hash](#nested-hashes) that can be depth-limited.
0 commit comments