Sha256: c49a557e87a5d33cc6d89c8b1d7002a79330c3a96e5d9d2630c7a2c431cd80b6

Contents?: true

Size: 788 Bytes

Versions: 1

Compression:

Stored size: 788 Bytes

Contents

require 'rubygems'
begin
  require 'dm-core'
  require 'dm-migrations'
rescue LoadError => e
  raise Capcode::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::Logger.new(logfile, :debug)
      DataMapper.setup(:default, dbconfig)
      DataMapper.auto_upgrade!
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capcode-base-datamapper-0.2.0 lib/capcode/base/dm.rb