Aura
→
AuraHierarchy
AuraHierarchy
Used on models that have children and parents.
Description
This automatically gives models parent/child support.
How to use
Use plugin :aura_hierarchy
in your model.
class Book < Sequel::Model
plugin :aura_hierarchy
end
Database setup
Add :parent_id
to your schema.
database.create_table :books do
foreign_key :parent_id
# ...
end
Example
Our Book
class can now have parents and children.
book = Book[2]
# Traversion
book.parent
book.children
book.siblings