Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tenacity

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tenacity

  • 0.6.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= Tenacity

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. So, writing code that manages relationships between objects backed by different databases hasn’t been nearly as easy as writing code to manage relationships between objects in the same database.

Tenacity aims to address this by providing a database client independent way of managing relationships between models backed by different databases.

Tenacity is heavily based on ActiveRecord's associations, and aims to behave in much the same way, supporting many of the same options.

== Example

class Car include MongoMapper::Document include Tenacity

t_has_many :wheels
t_has_one  :dashboard

end

class Wheel < ActiveRecord::Base include Tenacity

t_belongs_to :car

end

class Dashboard < CouchRest::Model::Base include Tenacity use_database MY_COUCHDB_DATABASE

t_belongs_to :car

end

car = Car.create

dashboard = Dashboard.create({}) car.dashboard = dashboard car.save

car.dashboard

car.dashboard.car_id

wheel_1 = Wheel.create wheel_2 = Wheel.create wheel_3 = Wheel.create wheels = [wheel_1, wheel_2, wheel_3] car.wheels = wheels car.save

wheel_1.car_id # car.id

car.wheels # [wheel_1, wheel_2, wheel_3]

car.wheel_ids # [wheel_1.id, wheel_2.id, wheel_3.id]

new_wheel = Wheel.create car.wheels << new_wheel car.save car.wheels # [wheel_1, wheel_2, wheel_3, new_wheel]

== Additional Usage Details

  • The directories that contain your model classes must be in your load path in order for Tenacity to find them.

== Supported Database Clients

  • ActiveRecord
  • CouchRest (CouchRest::Model and ExtendedDocument)
  • DataMapper
  • MongoMapper
  • Mongoid
  • Ripple
  • Sequel
  • Toystore

See EXTEND.rdoc for information on extending Tenacity to work with other database clients.

== Documentation

  • http://rdoc.info/github/jwood/tenacity/master/Tenacity/ClassMethods - Documentation on the associations supported, and their respective options
  • http://rdoc.info/github/jwood/tenacity/master/frames - Full API documentation

== Contributing to Tenacity

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Run the tests in ruby 1.8.7 and 1.9.2 on the master and active_support_2_x branches
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

== Development

  • Ruby 1.9.3 is required.

  • SQLite, MongoDB, Riak, and CouchDB must be installed, configured, and running.

  • Install the dependencies

    bundle install

  • Run the tests

    rake test

  • Code away!

== Copyright

Copyright (c) 2012 John Wood. See LICENSE.txt for further details.

FAQs

Package last updated on 22 Nov 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc