Sha256: 2cd62ba884892dace1def04cfef50a70a0dfdb354b93f01ab1a7c25731e5b588

Contents?: true

Size: 753 Bytes

Versions: 2

Compression:

Stored size: 753 Bytes

Contents

require 'rubygems'
begin
  require 'dm-core'
rescue LoadError => e
  raise MissingLibrary, "DataMapper could not be loaded (is it installed?): #{e.message}"
end
require 'yaml'
require 'logger'

module Capcode 
  Resource = DataMapper::Resource

  # use DataMapper
  # 
  # class Story < Capcode::Base
  #   include Capcode::Base
  #   property :id, Integer, :serial => true
  #   property :title, String
  #   property :body, String
  #   property :date, String
  # end  
  class Base
  end
  
  class << self
    def db_connect( dbfile, logfile ) #:nodoc:
      dbconfig = YAML::load(File.open(dbfile)).keys_to_sym
      DataMapper.setup(:default, dbconfig)
      DataMapper::Logger.new(logfile, :debug)
      DataMapper.auto_upgrade!
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
Capcode-0.8.9 lib/capcode/base/dm.rb
Capcode-0.8.8 lib/capcode/base/dm.rb