module Tenacity::OrmExt::Sequel

Tenacity relationships on Sequel objects require that certain columns exist on the associated table, and that join tables exist for one-to-many relationships. Take the following class for example:

class Car < Sequel::Model
  include Tenacity

  t_has_many    :wheels
  t_has_one     :dashboard
  t_belongs_to  :driver
end

t_belongs_to

The t_belongs_to association requires that a property exist in the table to hold the id of the assoicated object.

DB.create_table :cars do
  primary_key :id
  String :driver_id
end

t_has_one

The t_has_one association requires no special column in the table, since the associated object holds the foreign key.

t_has_many

The t_has_many association requires nothing special, as the associates are looked up using the associate class.

Public Class Methods

setup(model) click to toggle source
# File lib/tenacity/orm_ext/sequel.rb, line 40
def self.setup(model)
  require 'sequel'
  if model.ancestors.include?(::Sequel::Model)
    model.send :include, Sequel::InstanceMethods
    model.extend Sequel::ClassMethods
  end
rescue LoadError
  # Sequel not available
end