Module DataMapper::Is::Tree::InstanceMethods
In: lib/data_mapper/is/tree.rb
lib/data_mapper/is/tree.rb

Methods

Public Instance methods

Returns list of ancestors, starting with the root.

  grandchild1.ancestors # => [root, child]

[Source]

    # File lib/data_mapper/is/tree.rb, line 89
89:         def ancestors
90:           node, nodes = self, []
91:           nodes << node = node.parent while node.parent
92:           nodes.reverse
93:         end

Returns list of ancestors, starting with the root.

  grandchild1.ancestors # => [root, child]

[Source]

    # File lib/data_mapper/is/tree.rb, line 89
89:         def ancestors
90:           node, nodes = self, []
91:           nodes << node = node.parent while node.parent
92:           nodes.reverse
93:         end

Returns all children of the current node’s parent.

  grandchild1.generation # => [grandchild1, grandchild2]

[Source]

     # File lib/data_mapper/is/tree.rb, line 114
114:         def generation
115:           parent ? parent.children : self.class.roots
116:         end

Returns all children of the current node’s parent.

  grandchild1.generation # => [grandchild1, grandchild2]

[Source]

     # File lib/data_mapper/is/tree.rb, line 114
114:         def generation
115:           parent ? parent.children : self.class.roots
116:         end

Returns the root node of the current node’s tree.

          grandchild1.root # => root

[Source]

     # File lib/data_mapper/is/tree.rb, line 98
 98:         def root
 99:           node = self
100:           node = node.parent while node.parent
101:           node
102:         end

Returns the root node of the current node’s tree.

          grandchild1.root # => root

[Source]

     # File lib/data_mapper/is/tree.rb, line 98
 98:         def root
 99:           node = self
100:           node = node.parent while node.parent
101:           node
102:         end
self_and_siblings()

Alias for generation

self_and_siblings()

Alias for generation

Returns all siblings of the current node.

  grandchild1.siblings # => [grandchild2]

[Source]

     # File lib/data_mapper/is/tree.rb, line 107
107:         def siblings
108:           generation - [self]
109:         end

Returns all siblings of the current node.

  grandchild1.siblings # => [grandchild2]

[Source]

     # File lib/data_mapper/is/tree.rb, line 107
107:         def siblings
108:           generation - [self]
109:         end

[Validate]