Module Sequel::Plugins::Tree::ClassMethods
In: lib/sequel/plugins/tree.rb

Methods

Attributes

parent_column  [RW]  The symbol for the column containing the value pointing to the parent of the leaf.
tree_order  [RW]  The column symbol or array of column symbols on which to order the tree.

Public Instance methods

Copy the parent_column and order_column to the subclass.

[Source]

    # File lib/sequel/plugins/tree.rb, line 54
54:         def inherited(subclass)
55:           super
56:           subclass.parent_column = parent_column
57:           subclass.tree_order = tree_order 
58:         end

Returns list of all root nodes (those with no parent nodes).

  TreeClass.roots # => [root1, root2]

[Source]

    # File lib/sequel/plugins/tree.rb, line 63
63:         def roots
64:           roots_dataset.all
65:         end

Returns the dataset for retrieval of all root nodes

  TreeClass.roots_dataset => Sequel#Dataset

[Source]

    # File lib/sequel/plugins/tree.rb, line 70
70:         def roots_dataset
71:           ds = filter(parent_column => nil)
72:           ds = ds.order(*tree_order) if tree_order
73:           ds
74:         end

[Validate]