Module: Low::Mongo

Included in:
Local, Remote
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

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

#connectionObject

The environment’s Mongo::Connection instance.



23
24
25
# File 'lib/low/mongo.rb', line 23

def connection
  @connection ||= ::Mongo::MongoClient.new(host)
end

#databaseObject

The database ‘#db` will use - must be overriden.



33
34
# File 'lib/low/mongo.rb', line 33

def database
end

#dbObject

The environment’s Mongo::DB instance.



13
14
15
# File 'lib/low/mongo.rb', line 13

def db
  @db ||= connection.db(database)
end

#gridObject

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

#hostObject

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

#passwordObject



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

#usernameObject



36
37
# File 'lib/low/mongo.rb', line 36

def username
end