Permalink
Browse files

Implement _build_dbh in the Core role

  • Loading branch information...
autarch committed Apr 1, 2013
1 parent 7e55981 commit 7291674192c4e7feb49584ff60b59df09d295046
Showing with 13 additions and 11 deletions.
  1. +13 −11 lib/Database/Migrator/Core.pm
@@ -227,19 +227,21 @@ sub _build_logger {
return Log::Dispatch->new( outputs => [$outputs] );
}
-around _build_dbh => sub {
- my $orig = shift;
+sub _build_dbh {
my $self = shift;
- my $dbh = $self->$orig(@_);
-
- $dbh->{RaiseError} = 1;
- $dbh->{PrintError} = 1;
- $dbh->{PrintWarn} = 1;
- $dbh->{ShowErrorStatement} = 1;
-
- return $dbh;
-};
+ my ($driver) = ( ref $self ) =~ /::(\w+)$/;
+
+ return DBI->connect(
+ 'dbi:' . $driver . ':database=' . $self->database(),
+ $self->username(),
+ $self->password(),
+ RaiseError => 1,
+ PrintError => 1,
+ PrintWarn => 1,
+ ShowErrorStatement => 1,
+ );
+}
sub _numeric_or_alpha_sort {
my ( $a_num, $a_alpha ) = $a->basename() =~ /^(\d+)(.+)/;

0 comments on commit 7291674

Please sign in to comment.