From: Rafael Kitover Date: Mon, 4 May 2009 18:07:47 +0000 (+0000) Subject: support hashrefs for connect_replicants X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2cd3ccc410f4130275d001d797ccc914e24068e9;p=dbsrgits%2FDBIx-Class-Historic.git support hashrefs for connect_replicants --- diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm b/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm index 76ca7f2..d862327 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm @@ -4,6 +4,7 @@ use Moose; use MooseX::AttributeHelpers; use DBIx::Class::Storage::DBI::Replicated::Replicant; use List::Util qw(sum); +use Scalar::Util (); =head1 NAME @@ -149,8 +150,15 @@ sub connect_replicants { my @newly_created = (); foreach my $connect_info (@_) { + $connect_info = [ $connect_info ] + if Scalar::Util::reftype($connect_info) ne 'ARRAY'; + my $replicant = $self->connect_replicant($schema, $connect_info); - my ($key) = ($connect_info->[0]=~m/^dbi\:.+\:(.+)$/); + + my $key = $connect_info->[0]; + $key = $key->{dsn} if Scalar::Util::reftype($key) eq 'HASH'; + ($key) = ($key =~ m/^dbi\:.+\:(.+)$/); + $self->set_replicant( $key => $replicant); push @newly_created, $replicant; }