Class: MongoHelper

Inherits:
Base
  • Object
show all
Includes:
Mongo
Defined in:
lib/whos_using_what/no_sql/mongo_helper.rb

Instance Attribute Summary

Attributes inherited from Base

#set_paths

Class Method Summary collapse

Methods inherited from Base

set_paths

Class Method Details

.get_connectionObject



12
13
14
15
16
17
18
19
20
# File 'lib/whos_using_what/no_sql/mongo_helper.rb', line 12

def self.get_connection
  return @db_connection if @db_connection
  db = URI.parse(ENV["mongo.uri"].strip)
  db_name = db.path.gsub(/^\//, '')
  @db_connection = Mongo::Connection.new(db.host, db.port).db(db_name)
  @db_connection.authenticate(db.user, db.password) unless (db.user.nil? || db.user.nil?)
  @db_connection

end

.get_mongo_connectionObject



37
38
39
# File 'lib/whos_using_what/no_sql/mongo_helper.rb', line 37

def self.get_mongo_connection
  @db_connection
end