lib/dbcp/database.rb in dbcp-0.0.1 vs lib/dbcp/database.rb in dbcp-0.1.0
- old
+ new
@@ -1,7 +1,8 @@
module Dbcp
class Database
+ class BlankDatabaseDefinition < StandardError; end
class UnsupportedDatabaseAdapter < StandardError; end
class << self
def build(args)
klass_for_adapter(args['adapter']).new args
@@ -11,10 +12,12 @@
klass = case adapter
when /mysql/
MysqlDatabase
when /postgres/
PostgresDatabase
+ when nil, ''
+ raise BlankDatabaseDefinition.new("No database adapter was provided.")
else
raise UnsupportedDatabaseAdapter.new("Unsupported database adapter: #{adapter}")
end
end
end
@@ -22,9 +25,10 @@
include Virtus.value_object
values do
attribute :adapter
attribute :database
attribute :host, String, default: 'localhost'
+ attribute :port, Fixnum
attribute :socket
attribute :username
attribute :password
end
end