Module: Sequel::Plugins::Tree::ClassMethods
- Defined in:
- lib/sequel/plugins/tree.rb
Instance Attribute Summary collapse
-
#parent_column ⇒ Object
The symbol for the column containing the value pointing to the parent of the leaf.
-
#tree_order ⇒ Object
The column symbol or array of column symbols on which to order the tree.
Instance Method Summary collapse
-
#inherited(subclass) ⇒ Object
Copy the
parent_column
andorder_column
to the subclass. -
#roots ⇒ Object
Returns list of all root nodes (those with no parent nodes).
-
#roots_dataset ⇒ Object
Returns the dataset for retrieval of all root nodes.
Instance Attribute Details
#parent_column ⇒ Object
The symbol for the column containing the value pointing to the parent of the leaf.
56 57 58 |
# File 'lib/sequel/plugins/tree.rb', line 56 def parent_column @parent_column end |
#tree_order ⇒ Object
The column symbol or array of column symbols on which to order the tree.
52 53 54 |
# File 'lib/sequel/plugins/tree.rb', line 52 def tree_order @tree_order end |
Instance Method Details
#inherited(subclass) ⇒ Object
Copy the parent_column
and order_column
to the subclass.
59 60 61 62 63 |
# File 'lib/sequel/plugins/tree.rb', line 59 def inherited(subclass) super subclass.parent_column = parent_column subclass.tree_order = tree_order end |
#roots ⇒ Object
Returns list of all root nodes (those with no parent nodes).
TreeClass.roots # => [root1, root2]
68 69 70 |
# File 'lib/sequel/plugins/tree.rb', line 68 def roots roots_dataset.all end |