Class: MongoAgent::Db
- Inherits:
-
Object
- Object
- MongoAgent::Db
- Defined in:
- lib/mongo_agent/db.rb
Overview
MongoAgent::Db is a class that is meant to be extended by MongoAgent classes. It stores shared code to instantiate and provide access to a MongoDB Document Store and Moped::Session object for use by the extending classes to access their MongoDB Document Store
It depends on the following environment variables to configure its MongoDB connect:
MONGO_HOST: host URL for the MongoDB, can be in any form that mongod itself can
use, e.g. host:port, etc.
MONGO_DB: the name of the Document store in the MongoDB to use for all activities
will be created if does not exist
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
This holds the Moped::Session object that can be used to query information from the MongoDB hosted by the MONGO_HOST environment variable.
Instance Method Summary collapse
-
#build_db ⇒ Object
This is for internal use by SpreadsheetAgent classes that extend SpreadsheetAgent::Db.
Instance Attribute Details
#db ⇒ Object (readonly)
This holds the Moped::Session object that can be used to query information from the MongoDB
hosted by the MONGO_HOST environment variable
19 20 21 |
# File 'lib/mongo_agent/db.rb', line 19 def db @db end |
Instance Method Details
#build_db ⇒ Object
This is for internal use by SpreadsheetAgent classes that extend SpreadsheetAgent::Db
22 23 24 25 |
# File 'lib/mongo_agent/db.rb', line 22 def build_db @db = Moped::Session.new([ ENV['MONGO_HOST'] ]) @db.use ENV['MONGO_DB'] end |