X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FAttribute%2FNative%2FTrait%2FCounter.pm;h=170e2cf078c31ca2fe8bff32088b18094bc30d40;hb=60f0816092ffe11986388dd2bba56a356b697843;hp=6c47654770b640cd6d28297dc450ea21a56b93ec;hpb=8b5074ce1a5038824f1e1177cd00d1bcfec5a9fb;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Attribute/Native/Trait/Counter.pm b/lib/Moose/Meta/Attribute/Native/Trait/Counter.pm index 6c47654..170e2cf 100644 --- a/lib/Moose/Meta/Attribute/Native/Trait/Counter.pm +++ b/lib/Moose/Meta/Attribute/Native/Trait/Counter.pm @@ -2,7 +2,7 @@ package Moose::Meta::Attribute::Native::Trait::Counter; use Moose::Role; -our $VERSION = '0.97'; +our $VERSION = '1.09'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -53,19 +53,15 @@ Moose::Meta::Attribute::Native::Trait::Counter - Helper trait for counters my $page = MyHomePage->new(); $page->inc_counter; # same as $page->counter( $page->counter + 1 ); $page->dec_counter; # same as $page->counter( $page->counter - 1 ); + + my $count_by_twos = 2; + $page->inc_counter($count_by_twos); =head1 DESCRIPTION This module provides a simple counter attribute, which can be -incremented and decremented. - -If your attribute definition does not include any of I, I, -I or I but does use the C trait, -then this module applies defaults as in the L -above. This allows for a very basic counter definition: - - has 'foo' => (traits => ['Counter']); - $obj->inc_foo; +incremented and decremented by arbitrary amounts. The default +amount of change is one. =head1 PROVIDED METHODS @@ -80,15 +76,15 @@ the attribute. Set the counter to the specified value. -=item B +=item B -Increments the value stored in this slot by 1. Providing an argument will -cause the counter to be increased by specified amount. +Increase the attribute value by the amount of the argument. +No argument increments the value by 1. -=item B +=item B -Decrements the value stored in this slot by 1. Providing an argument will -cause the counter to be increased by specified amount. +Decrease the attribute value by the amount of the argument. +No argument decrements the value by 1. =item B