module Tenacity::OrmExt::DataMapper

Tenacity relationships on DataMapper objects require that certain columns exist on the associated table. Take the following class for example:

class Car
  include DataMapper::Resource
  include Tenacity

  property :id, Serial
  property :driver_id, String

  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.

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/datamapper.rb, line 38
def self.setup(model)
  require 'datamapper'
  if model.included_modules.include?(::DataMapper::Resource)
    model.send :include, DataMapper::InstanceMethods
    model.extend DataMapper::ClassMethods
  end
rescue LoadError
  # DataMapper not available
end