From: Shawn M Moore Date: Sun, 25 May 2008 01:44:24 +0000 (+0000) Subject: Simplify MooseX::AttributeHelpers::Counter into just using the Counter trait X-Git-Tag: 0.18_01~14 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0224b8d27f1b2c4646d59fdb4e2cc0d2e793053f;p=gitmo%2FMooseX-AttributeHelpers.git Simplify MooseX::AttributeHelpers::Counter into just using the Counter trait --- diff --git a/lib/MooseX/AttributeHelpers/Counter.pm b/lib/MooseX/AttributeHelpers/Counter.pm index 2da3971..a67d043 100644 --- a/lib/MooseX/AttributeHelpers/Counter.pm +++ b/lib/MooseX/AttributeHelpers/Counter.pm @@ -5,41 +5,8 @@ use Moose; our $VERSION = '0.03'; our $AUTHORITY = 'cpan:STEVAN'; -use MooseX::AttributeHelpers::MethodProvider::Counter; - -extends 'MooseX::AttributeHelpers::Base'; - -has '+method_provider' => ( - default => 'MooseX::AttributeHelpers::MethodProvider::Counter' -); - -sub helper_type { 'Num' } - -before 'process_options_for_provides' => sub { - my ($self, $options, $name) = @_; - - # Set some default attribute options here unless already defined - if ((my $type = $self->helper_type) && !exists $options->{isa}){ - $options->{isa} = $type; - } - - $options->{is} = 'ro' unless exists $options->{is}; - $options->{default} = 0 unless exists $options->{default}; -}; - -after 'check_provides_values' => sub { - my $self = shift; - my $provides = $self->provides; - - unless (scalar keys %$provides) { - my $method_constructors = $self->method_constructors; - my $attr_name = $self->name; - - foreach my $method (keys %$method_constructors) { - $provides->{$method} = ($method . '_' . $attr_name); - } - } -}; +extends 'Moose::Meta::Attribute'; +with 'MooseX::AttributeHelpers::Trait::Counter'; no Moose;