Permalink
Browse files

Merge pull request #384 from RobertLowe/master

Fix: Uninitialized Class Variable @@database_name
  • Loading branch information...
2 parents 2d807c0 + 8ebe0ea commit 4b96535b98d157e7d94a59411213726cbec67867 @bkeepers bkeepers committed Mar 30, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/mongo_mapper/connection.rb
@@ -3,6 +3,11 @@
module MongoMapper
module Connection
+ @@connection = nil
+ @@database = nil
+ @@database_name = nil
+ @@config = nil
+
# @api public
def connection
@@connection ||= Mongo::Connection.new
@@ -26,9 +31,7 @@ def database=(name)
# @api public
def database
- if @@database_name.blank?
- raise 'You forgot to set the default database name: MongoMapper.database = "foobar"'
- end
+ return nil if @@database_name.blank?
@@database ||= MongoMapper.connection.db(@@database_name)
end

0 comments on commit 4b96535

Please sign in to comment.