Module: Capcode

Defined in:
lib/capcode/base/mongoid.rb

Defined Under Namespace

Classes: Base

Constant Summary collapse

Resource =
Mongoid::Document

Class Method Summary collapse

Class Method Details

.db_connect(dbfile, logfile) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/capcode/base/mongoid.rb', line 17

def db_connect( dbfile, logfile )
  dbconfig = YAML::load(File.open(dbfile)).keys_to_sym
  
  connection = Mongo::Connection.new(dbconfig[:host], dbconfig[:port])
  Mongoid.database = connection.db(dbconfig[:database])
  if dbconfig[:username]
    Mongoid.database.authenticate(dbconfig[:username], dbconfig[:password])
  end
end