Sha256: 2837fc214dc1bd5781b4482a1ea146e9ad3f4f93fafa33e4d634f465eb645f7d

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

require 'data_mapper/associations/reference'
require 'data_mapper/associations/has_many_association'
require 'data_mapper/associations/belongs_to_association'
require 'data_mapper/associations/has_one_association'
require 'data_mapper/associations/has_and_belongs_to_many_association'

module DataMapper
  module Associations
  
    def self.included(base)
      base.extend(ClassMethods)
    end
    
    module ClassMethods
      
      def has_many(association_name, options = {})
        database.schema[self].associations << HasManyAssociation.new(self, association_name, options)
      end
      
      def belongs_to(association_name, options = {})
        database.schema[self].associations << BelongsToAssociation.new(self, association_name, options)
      end
      
      def has_and_belongs_to_many(association_name, options = {})
        database.schema[self].associations << HasAndBelongsToManyAssociation.new(self, association_name, options)
      end
      
      def has_one(association_name, options = {})
        database.schema[self].associations << HasOneAssociation.new(self, association_name, options)
      end
      
    end
    
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
datamapper-0.2.0 lib/data_mapper/associations.rb
datamapper-0.2.3 lib/data_mapper/associations.rb
datamapper-0.2.1 lib/data_mapper/associations.rb
datamapper-0.2.2 lib/data_mapper/associations.rb
datamapper-0.2.4 lib/data_mapper/associations.rb