Tenacity is a ruby gem that provides a database client independent way of managing relationships between models backed by different databases.
It is sometimes necessary, or advantageous, to use more than one database in a given application (polyglot persistence). However, most database clients do not support inter-database relationships. And, those that do support inter-database relationships only know how to work with the non-relational databases in a generic way. MongoMapper is great for working with MongoDB, as CouchRest is great for working with CouchDB. It would be a shame not be able to use great tools like these when working with their respective databases. Therefore, Tenacity’s goal is to provide simple object relationship management, while allowing you to use the database clients of your choice.
While supporting such relationships isn’t difficult, it can add quite a bit of boilerplate code to your project. And, the amount of boilerplate code increases the more complex the relationship becomes, especially when you consider that you cannot use foreign keys to maintain the integrity of your data. For example, what should happen to a child object if its parent is deleted? Should the delete be allowed to proceed? If so, should the child object be deleted as well, or just have its property linking it back to the deleted parent nullified? Tenacity aims to provide a simple and standard way to specify the behavior of these inter-database relationships.
Tenacity is heavily based on ActiveRecord’s associations, and aims to behave in much the same way, supporting many of the same options.
gem install tenacity