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

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

Instance Method Summary collapse

Instance Method Details

#associationsObject



17
18
19
# File 'lib/novelys_mongo_mapper/plugins/associations.rb', line 17

def associations
  @associations ||= HashWithIndifferentAccess.new
end

#associations=(hash) ⇒ Object



21
22
23
# File 'lib/novelys_mongo_mapper/plugins/associations.rb', line 21

def associations=(hash)
  @associations = hash
end

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



5
6
7
# File 'lib/novelys_mongo_mapper/plugins/associations.rb', line 5

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

#inherited(subclass) ⇒ Object



25
26
27
28
# File 'lib/novelys_mongo_mapper/plugins/associations.rb', line 25

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

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



9
10
11
# File 'lib/novelys_mongo_mapper/plugins/associations.rb', line 9

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

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



13
14
15
# File 'lib/novelys_mongo_mapper/plugins/associations.rb', line 13

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