Module: Sequel::Plugins::Tree::ClassMethods

Defined in:
lib/sequel_tree.rb

Instance Method Summary collapse

Instance Method Details

#rootsObject

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

TreeClass.roots # => [root1, root2]


37
38
39
# File 'lib/sequel_tree.rb', line 37

def roots
  roots_dataset.all
end

#roots_datasetObject

Returns the dataset for retrieval of all root nodes

TreeClass.roots_dataset => Sequel#Dataset


44
45
46
# File 'lib/sequel_tree.rb', line 44

def roots_dataset
  filter(@parent_column => nil).order(@order_column)
end