Module | DataMapper::Associations::ClassMethods |
In: |
lib/data_mapper/associations.rb
lib/data_mapper/associations.rb |
Adds the following methods for query of a single associated object:
# File lib/data_mapper/associations.rb, line 80 80: def belongs_to(association_name, options = {}) 81: database.schema[self].associations << BelongsToAssociation.new(self, association_name, options) 82: end
Adds the following methods for query of a single associated object:
# File lib/data_mapper/associations.rb, line 80 80: def belongs_to(association_name, options = {}) 81: database.schema[self].associations << BelongsToAssociation.new(self, association_name, options) 82: end
Associates two classes via an intermediate join table.
Options are:
# File lib/data_mapper/associations.rb, line 99 99: def has_and_belongs_to_many(association_name, options = {}) 100: database.schema[self].associations << HasAndBelongsToManyAssociation.new(self, association_name, options) 101: end
Associates two classes via an intermediate join table.
Options are:
# File lib/data_mapper/associations.rb, line 99 99: def has_and_belongs_to_many(association_name, options = {}) 100: database.schema[self].associations << HasAndBelongsToManyAssociation.new(self, association_name, options) 101: end
Adds the following methods for query of a single associated object:
Options are:
Option examples:
has_many :favourite_fruits, :class => 'Fruit', :dependent => :destroy
# File lib/data_mapper/associations.rb, line 41 41: def has_many(association_name, options = {}) 42: database.schema[self].associations << HasManyAssociation.new(self, association_name, options) 43: end
Adds the following methods for query of a single associated object:
Options are:
Option examples:
has_many :favourite_fruits, :class => 'Fruit', :dependent => :destroy
# File lib/data_mapper/associations.rb, line 41 41: def has_many(association_name, options = {}) 42: database.schema[self].associations << HasManyAssociation.new(self, association_name, options) 43: end
Adds the following methods for query of a single associated object:
The declaration can also include an options hash to specialize the behavior of the association.
Options are:
Option examples:
has_one :favourite_fruit, :class => 'Fruit', :foreign_key => 'devourer_id'
# File lib/data_mapper/associations.rb, line 67 67: def has_one(association_name, options = {}) 68: database.schema[self].associations << HasManyAssociation.new(self, association_name, options) 69: end
Adds the following methods for query of a single associated object:
The declaration can also include an options hash to specialize the behavior of the association.
Options are:
Option examples:
has_one :favourite_fruit, :class => 'Fruit', :foreign_key => 'devourer_id'
# File lib/data_mapper/associations.rb, line 67 67: def has_one(association_name, options = {}) 68: database.schema[self].associations << HasManyAssociation.new(self, association_name, options) 69: end