From: Florian Ragwitz Date: Sat, 2 Jan 2010 17:31:43 +0000 (+0000) Subject: Port replicated storage from MXAH to native traits. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c4d78acbeb6e3f3d4a33d457f4b8a6fef342cc49;p=dbsrgits%2FDBIx-Class-Historic.git Port replicated storage from MXAH to native traits. --- diff --git a/Makefile.PL b/Makefile.PL index dd41d6f..c607b11 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -48,8 +48,7 @@ requires 'Sub::Name' => '0.04'; requires 'Data::Dumper::Concise' => '1.000'; my %replication_requires = ( - 'Moose', => '0.87', - 'MooseX::AttributeHelpers' => '0.21', + 'Moose', => '0.90', 'MooseX::Types', => '0.16', 'namespace::clean' => '0.11', 'Hash::Merge', => '0.11', diff --git a/lib/DBIx/Class/Storage/DBI/Replicated.pm b/lib/DBIx/Class/Storage/DBI/Replicated.pm index 1589b5f..d8a5f6d 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated.pm @@ -7,8 +7,7 @@ BEGIN { ## use, so we explicitly test for these. my %replication_required = ( - 'Moose' => '0.87', - 'MooseX::AttributeHelpers' => '0.21', + 'Moose' => '0.90', 'MooseX::Types' => '0.16', 'namespace::clean' => '0.11', 'Hash::Merge' => '0.11' @@ -119,8 +118,7 @@ to force a query to run against Master when needed. Replicated Storage has additional requirements not currently part of L - Moose => '0.87', - MooseX::AttributeHelpers => '0.20', + Moose => '0.90', MooseX::Types => '0.16', namespace::clean => '0.11', Hash::Merge => '0.11' diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm b/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm index e5fa1a1..a7a1dfa 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm @@ -1,7 +1,6 @@ package DBIx::Class::Storage::DBI::Replicated::Pool; use Moose; -use MooseX::AttributeHelpers; use DBIx::Class::Storage::DBI::Replicated::Replicant; use List::Util 'sum'; use Scalar::Util 'reftype'; @@ -125,26 +124,31 @@ removes the replicant under $key from the pool has 'replicants' => ( is=>'rw', - metaclass => 'Collection::Hash', + traits => ['Hash'], isa=>HashRef['Object'], default=>sub {{}}, - provides => { - 'set' => 'set_replicant', - 'get' => 'get_replicant', - 'empty' => 'has_replicants', - 'count' => 'num_replicants', - 'delete' => 'delete_replicant', - 'values' => 'all_replicant_storages', + handles => { + 'set_replicant' => 'set', + 'get_replicant' => 'get', + 'has_replicants' => 'is_empty', + 'num_replicants' => 'count', + 'delete_replicant' => 'delete', + 'all_replicant_storages' => 'values', }, ); +around has_replicants => sub { + my ($orig, $self) = @_; + return !$self->$orig; +}; + has next_unknown_replicant_id => ( is => 'rw', - metaclass => 'Counter', + traits => ['Counter'], isa => Int, default => 1, - provides => { - inc => 'inc_unknown_replicant_id' + handles => { + 'inc_unknown_replicant_id' => 'inc', }, );