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

Methods

freeze   roots   roots_dataset  

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

Should freeze tree order if it is an array when freezing the model class.

[Source]

    # File lib/sequel/plugins/tree.rb, line 67
67:         def freeze
68:           @tree_order.freeze if @tree_order.is_a?(Array)
69:         
70:           super
71:         end

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

  TreeClass.roots # => [root1, root2]

[Source]

    # File lib/sequel/plugins/tree.rb, line 76
76:         def roots
77:           roots_dataset.all
78:         end

Returns the dataset for retrieval of all root nodes

  TreeClass.roots_dataset # => Sequel::Dataset instance

[Source]

    # File lib/sequel/plugins/tree.rb, line 83
83:         def roots_dataset
84:           ds = where(Sequel.or(Array(parent_column).zip([])))
85:           ds = ds.order(*tree_order) if tree_order
86:           ds
87:         end

[Validate]