Class: MinceMongoDb::Connection
- Inherits:
-
Object
- Object
- MinceMongoDb::Connection
- Includes:
- Singleton
- Defined in:
- lib/mince_mongo_db/connection.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#db ⇒ Object
Returns the value of attribute db.
Class Method Summary collapse
Instance Method Summary collapse
- #auth ⇒ Object
- #auth_provided? ⇒ Boolean
- #database_name ⇒ Object
-
#initialize ⇒ Connection
constructor
A new instance of Connection.
Constructor Details
#initialize ⇒ Connection
Returns a new instance of Connection.
19 20 21 |
# File 'lib/mince_mongo_db/connection.rb', line 19 def initialize self.connection = Mongo::Connection.new(Config.database_host) end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
9 10 11 |
# File 'lib/mince_mongo_db/connection.rb', line 9 def connection @connection end |
#db ⇒ Object
Returns the value of attribute db.
9 10 11 |
# File 'lib/mince_mongo_db/connection.rb', line 9 def db @db end |
Class Method Details
.connection ⇒ Object
11 12 13 |
# File 'lib/mince_mongo_db/connection.rb', line 11 def self.connection instance.connection end |
.db ⇒ Object
15 16 17 |
# File 'lib/mince_mongo_db/connection.rb', line 15 def self.db instance.db end |
Instance Method Details
#auth ⇒ Object
29 30 31 |
# File 'lib/mince_mongo_db/connection.rb', line 29 def auth db.authenticate(Config.username, Config.password) if auth_provided? end |
#auth_provided? ⇒ Boolean
33 34 35 |
# File 'lib/mince_mongo_db/connection.rb', line 33 def auth_provided? !!Config.username && !!Config.password end |
#database_name ⇒ Object
37 38 39 |
# File 'lib/mince_mongo_db/connection.rb', line 37 def database_name Config.database_name end |