Class: Insulin::MongoHandle

Inherits:
Object
  • Object
show all
Defined in:
lib/insulin/mongo_handle.rb

Overview

This class is a simple wrapper around a MongoDB connection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conf) ⇒ MongoHandle

Set up the connection as described by ‘conf’



12
13
14
15
16
# File 'lib/insulin/mongo_handle.rb', line 12

def initialize conf
  @conf = conf
  @connection = Mongo::Connection.new 
  @db = @connection.db @conf["database"]
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



9
10
11
# File 'lib/insulin/mongo_handle.rb', line 9

def connection
  @connection
end

#dbObject (readonly)

Returns the value of attribute db.



9
10
11
# File 'lib/insulin/mongo_handle.rb', line 9

def db
  @db
end

Instance Method Details

#drop_dbObject

Drop this database



19
20
21
# File 'lib/insulin/mongo_handle.rb', line 19

def drop_db
  @connection.drop_database @conf["database"]
end