[Bast-commits] r7447 - DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Replicated

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Mon Aug 31 02:58:44 GMT 2009


Author: caelum
Date: 2009-08-31 02:58:43 +0000 (Mon, 31 Aug 2009)
New Revision: 7447

Modified:
   DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm
Log:
make replicant dsn detection a bit nicer

Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm	2009-08-31 02:36:08 UTC (rev 7446)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm	2009-08-31 02:58:43 UTC (rev 7447)
@@ -159,19 +159,13 @@
     $connect_info = [ $connect_info ]
       if reftype $connect_info ne 'ARRAY';
 
-    my $replicant = $self->connect_replicant($schema, $connect_info);
-
     my $connect_coderef =
       (reftype($connect_info->[0])||'') eq 'CODE' ? $connect_info->[0]
         : (reftype($connect_info->[0])||'') eq 'HASH' &&
           $connect_info->[0]->{dbh_maker};
 
     my $dsn;
-    if (not $connect_coderef) {
-      $dsn = $connect_info->[0];
-      $dsn = $dsn->{dsn} if (reftype($dsn)||'') eq 'HASH';
-    }
-    else {
+    my $replicant = do {
 # yes this is evil, but it only usually happens once
       no warnings 'redefine';
       my $connect = \&DBI::connect;
@@ -179,9 +173,15 @@
         $dsn = $_[1];
         goto $connect;
       };
-      $connect_coderef->();
+      $self->connect_replicant($schema, $connect_info);
+    };
+
+    if (!$dsn && !$connect_coderef) {
+      $dsn = $connect_info->[0];
+      $dsn = $dsn->{dsn} if (reftype($dsn)||'') eq 'HASH';
     }
     $replicant->dsn($dsn);
+
     my ($key) = ($dsn =~ m/^dbi\:.+\:(.+)$/i);
 
     $self->set_replicant($key => $replicant);  




More information about the Bast-commits mailing list