Module: Dagable
- Defined in:
- lib/dagable.rb,
lib/dagable/edge.rb,
lib/dagable/model.rb,
lib/dagable/version.rb,
lib/dagable/ancestry.rb,
lib/dagable/associations.rb,
lib/dagable/instance_methods.rb,
lib/dagable/migration_helpers.rb,
lib/dagable/migrations/helper.rb,
lib/dagable/errors/cyclic_association.rb
Overview
Dagable provides directed acyclic graph (DAG) composition for ActiveRecord models using a dedicated ancestry table. It materializes all transitive paths so that traversal queries are single JOINs instead of recursive CTEs.
Quick start
class Category < ActiveRecord::Base
extend Dagable::Model
dagable
end
This gives the model add_child, add_parent, remove_child, remove_parent, and traversal methods (self_and_successors, self_and_predecessors, successors, predecessors).
Database tables
Each dagable model requires two supporting tables that can be created with Dagable::MigrationHelpers#create_dagable_tables:
-
{table}_edges — stores direct parent-child relationships
-
{table}_ancestries — stores all transitive paths with depth
Defined Under Namespace
Modules: Errors, InstanceMethods, MigrationHelpers, Migrations, Model Classes: Ancestry, Associations, Edge
Constant Summary collapse
- VERSION =
"0.1.1"