Module: Mongo::Model::Db::ClassMethods

Defined in:
lib/mongo/model/db.rb

Instance Method Summary collapse

Instance Method Details

#collection(name = nil, &block) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/mongo/model/db.rb', line 13

def collection name = nil, &block
  if name
    self.collection_name = name
  else
    db.collection(collection_name || default_collection_name)
  end
end

#db(name = nil) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/mongo/model/db.rb', line 4

def db name = nil
  if name
    self.db_name = name
  else
    Mongo.db db_name || Mongo::Model.default_database_name
  end
end