Module: MongoMapper::Associations::ClassMethods

Defined in:
lib/mongo_mapper/associations.rb

Instance Method Summary collapse

Instance Method Details

#associationsObject



16
17
18
# File 'lib/mongo_mapper/associations.rb', line 16

def associations
  @associations ||= HashWithIndifferentAccess.new
end

#associations=(hash) ⇒ Object



20
21
22
# File 'lib/mongo_mapper/associations.rb', line 20

def associations=(hash)
  @associations = hash
end

#belongs_to(association_id, options = {}, &extension) ⇒ Object



4
5
6
# File 'lib/mongo_mapper/associations.rb', line 4

def belongs_to(association_id, options={}, &extension)
  create_association(:belongs_to, association_id, options, &extension)
end

#inherited(subclass) ⇒ Object



24
25
26
27
# File 'lib/mongo_mapper/associations.rb', line 24

def inherited(subclass)
  subclass.associations = associations.dup
  super
end

#many(association_id, options = {}, &extension) ⇒ Object



8
9
10
# File 'lib/mongo_mapper/associations.rb', line 8

def many(association_id, options={}, &extension)
  create_association(:many, association_id, options, &extension)
end

#one(association_id, options = {}, &extension) ⇒ Object



12
13
14
# File 'lib/mongo_mapper/associations.rb', line 12

def one(association_id, options={}, &extension)
  create_association(:one, association_id, options, &extension)
end