Module: Capcode

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

Defined Under Namespace

Classes: Base

Constant Summary collapse

Resource =
DataMapper::Resource

Class Method Summary collapse

Class Method Details

.db_connect(dbfile, logfile) ⇒ Object

:nodoc:



27
28
29
30
31
32
33
34
# File 'lib/capcode/base/dm.rb', line 27

def db_connect( dbfile, logfile ) #:nodoc:
  dbconfig = YAML::load(File.open(dbfile)).keys_to_sym
  loglevel = (dbconfig.delete(:loglevel) || "error").to_sym
  DataMapper.finalize
  DataMapper::Logger.new(logfile, loglevel)
  DataMapper.setup(:default, dbconfig)
  DataMapper.auto_upgrade!
end