From: Rafael Kitover Date: Tue, 16 Feb 2010 10:09:58 +0000 (+0000) Subject: use OO interface of Hash::Merge for ::DBI::Replicated X-Git-Tag: v0.08120~35 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e666c5fd810f9103a8e2ae1994e45828169e703d;p=dbsrgits%2FDBIx-Class.git use OO interface of Hash::Merge for ::DBI::Replicated --- diff --git a/lib/DBIx/Class/Optional/Dependencies.pm b/lib/DBIx/Class/Optional/Dependencies.pm index 5d882e2..c1a4fe4 100644 --- a/lib/DBIx/Class/Optional/Dependencies.pm +++ b/lib/DBIx/Class/Optional/Dependencies.pm @@ -33,7 +33,7 @@ my $reqs = { req => { %$moose_basic, 'namespace::clean' => '0.11', - 'Hash::Merge' => '0.11', + 'Hash::Merge' => '0.12', }, pod => { title => 'Storage::Replicated', @@ -151,7 +151,7 @@ my $reqs = { rdbms_asa => { req => { - grep $_, @ENV{qw/DBICTEST_SYBASE_ASA_DSN DBICTEST_SYBASE_ASA_ODBC_DSN/} + (scalar grep $_, @ENV{qw/DBICTEST_SYBASE_ASA_DSN DBICTEST_SYBASE_ASA_ODBC_DSN/}) ? ( 'DateTime::Format::Strptime' => 0, ) : () diff --git a/lib/DBIx/Class/Storage/DBI/Replicated.pm b/lib/DBIx/Class/Storage/DBI/Replicated.pm index 7e84f7c..a5de335 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated.pm @@ -14,7 +14,7 @@ use DBIx::Class::Storage::DBI::Replicated::Balancer; use DBIx::Class::Storage::DBI::Replicated::Types qw/BalancerClassNamePart DBICSchema DBICStorageDBI/; use MooseX::Types::Moose qw/ClassName HashRef Object/; use Scalar::Util 'reftype'; -use Hash::Merge 'merge'; +use Hash::Merge; use List::Util qw/min max/; use namespace::clean -except => 'meta'; @@ -384,10 +384,12 @@ around connect_info => sub { my $wantarray = wantarray; + my $merge = Hash::Merge->new; + my %opts; for my $arg (@$info) { next unless (reftype($arg)||'') eq 'HASH'; - %opts = %{ merge($arg, \%opts) }; + %opts = %{ $merge->merge($arg, \%opts) }; } delete $opts{dsn}; @@ -396,7 +398,7 @@ around connect_info => sub { if $opts{pool_type}; $self->pool_args( - merge((delete $opts{pool_args} || {}), $self->pool_args) + $merge->merge((delete $opts{pool_args} || {}), $self->pool_args) ); $self->pool($self->_build_pool) @@ -408,7 +410,7 @@ around connect_info => sub { if $opts{balancer_type}; $self->balancer_args( - merge((delete $opts{balancer_args} || {}), $self->balancer_args) + $merge->merge((delete $opts{balancer_args} || {}), $self->balancer_args) ); $self->balancer($self->_build_balancer) @@ -553,7 +555,8 @@ around connect_replicants => sub { $self->throw_exception('too many hashrefs in connect_info') if @hashes > 2; - my %opts = %{ merge(reverse @hashes) }; + my $merge = Hash::Merge->new; + my %opts = %{ $merge->merge(reverse @hashes) }; # delete them splice @$r, $i+1, ($#{$r} - $i), (); @@ -566,7 +569,7 @@ around connect_replicants => sub { delete $master_opts{dbh_maker}; # merge with master - %opts = %{ merge(\%opts, \%master_opts) }; + %opts = %{ $merge->merge(\%opts, \%master_opts) }; # update $r->[$i] = \%opts;