Methods
Public Instance methods
[ show source ]
# File vendor/rails/activerecord/lib/active_record/acts/tree.rb, line 68
68: def ancestors
69: node, nodes = self, []
70: nodes << node = node.parent while node.parent
71: nodes
72: end
Returns the root node of the tree.
[ show source ]
# File vendor/rails/activerecord/lib/active_record/acts/tree.rb, line 75
75: def root
76: node = self
77: node = node.parent while node.parent
78: node
79: end
Returns all siblings and a reference to the current node.
subchild1.self_and_siblings # => [subchild1, subchild2]
[ show source ]
# File vendor/rails/activerecord/lib/active_record/acts/tree.rb, line 91
91: def self_and_siblings
92: parent ? parent.children : self.class.roots
93: end
Returns all siblings of the current node.
subchild1.siblings # => [subchild2]
[ show source ]
# File vendor/rails/activerecord/lib/active_record/acts/tree.rb, line 84
84: def siblings
85: self_and_siblings - [self]
86: end