Module: Low::Mongo
- Defined in:
- lib/low/mongo.rb,
lib/low/mongo/util.rb,
lib/low/mongo/heroku.rb
Overview
The ‘Mongo` module defines an interface for a Mongo helper class. It also includes two basic classes, `Local` and `Remote`.
Defined Under Namespace
Modules: Heroku, Util Classes: Local, Remote
Instance Method Summary collapse
-
#[](collection) ⇒ Object
Simple access to a Mongo::Collection instance.
-
#connection ⇒ Object
The environment’s Mongo::Connection instance.
-
#database ⇒ Object
The database ‘#db` will use - must be overriden.
-
#db ⇒ Object
The environment’s Mongo::DB instance.
-
#grid ⇒ Object
The environment’s Mongo::Grid instance - a file store.
-
#host ⇒ Object
The host that ‘#connection` will use - either this or `#connection` should be overriden.
- #password ⇒ Object
-
#reset_connection! ⇒ Object
Force a new connection the next time one is needed.
- #username ⇒ Object
Instance Method Details
#[](collection) ⇒ Object
Simple access to a Mongo::Collection instance.
8 9 10 |
# File 'lib/low/mongo.rb', line 8 def [](collection) db[collection] end |
#connection ⇒ Object
The environment’s Mongo::Connection instance.
23 24 25 |
# File 'lib/low/mongo.rb', line 23 def connection @connection ||= ::Mongo::MongoClient.new(host) end |
#database ⇒ Object
The database ‘#db` will use - must be overriden.
33 34 |
# File 'lib/low/mongo.rb', line 33 def database end |
#db ⇒ Object
The environment’s Mongo::DB instance.
13 14 15 |
# File 'lib/low/mongo.rb', line 13 def db @db ||= connection.db(database) end |
#grid ⇒ Object
The environment’s Mongo::Grid instance - a file store.
18 19 20 |
# File 'lib/low/mongo.rb', line 18 def grid @grid ||= ::Mongo::Grid.new(db) end |
#host ⇒ Object
The host that ‘#connection` will use - either this or `#connection` should be overriden.
29 30 |
# File 'lib/low/mongo.rb', line 29 def host end |
#password ⇒ Object
39 40 |
# File 'lib/low/mongo.rb', line 39 def password end |
#reset_connection! ⇒ Object
Force a new connection the next time one is needed
43 44 45 46 47 |
# File 'lib/low/mongo.rb', line 43 def reset_connection! @grid = nil @db = nil @connection = nil end |
#username ⇒ Object
36 37 |
# File 'lib/low/mongo.rb', line 36 def username end |