Module: MongoMapper::Plugins::Associations::ClassMethods

Defined in:
lib/mongo_mapper/plugins/associations.rb

Instance Method Summary collapse

Instance Method Details

#associationsObject



23
24
25
# File 'lib/mongo_mapper/plugins/associations.rb', line 23

def associations
  @associations ||= HashWithIndifferentAccess.new
end

#associations=(hash) ⇒ Object



27
28
29
# File 'lib/mongo_mapper/plugins/associations.rb', line 27

def associations=(hash)
  @associations = hash
end

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



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

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

#inherited(subclass) ⇒ Object



6
7
8
9
# File 'lib/mongo_mapper/plugins/associations.rb', line 6

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

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



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

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

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



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

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