Enhances ActiveRecord with nested hierarchies.
Ruby
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.github
doc
lib
spec
.codeclimate.yml
.gitignore
.rubocop.yml
.rubocop_todo.yml
.ruby-version
.todo.reek
CHANGES.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Gemfile
Guardfile
LICENSE.md
README.md
Rakefile
circle.yml
lineage.gemspec

README.md

Lineage

Gem Version Code Climate Maintainability Code Climate Test Coverage Circle CI Status

A implementation of the Closure Table pattern for ActiveRecord models. This uses two tables to maintain the ancestor/descendant relationship for all branches of a particular model. For example, you might have web pages you want to represent in a nested hierarchy which would yield the following table structure:

  • Page (i.e. pages)
  • PageBranch (i.e. page_branches)

Assuming the following page hierarchy:

Branch Graph

The page_branches table would consist of the following data:

Branch Table

Table of Contents

Features

  • Database integrity via the Closure Table pattern.

Requirements

  1. Ruby 2.5.x.
  2. Ruby on Rails 5.x.x.

Setup

Type the following to install:

gem install lineage

Add the following to your Gemfile:

gem "lineage"

Usage

Add the following to any model you wish to enable with lineage support:

lineage

Tests

To test, run:

bundle exec rake

Versioning

Read Semantic Versioning for details. Briefly, it means:

  • Major (X.y.z) - Incremented for any backwards incompatible public API changes.
  • Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
  • Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.

Code of Conduct

Please note that this project is released with a CODE OF CONDUCT. By participating in this project you agree to abide by its terms.

Contributions

Read CONTRIBUTING for details.

License

Copyright 2010 Alchemists. Read LICENSE for details.

History

Read CHANGES for details. Built with Gemsmith.

Credits

Developed by Brooke Kuhlmann at Alchemists.