NAME
MooseX::AttributeHelpers::Counter
SYNOPSIS
package MyHomePage;
use Moose;
use MooseX::AttributeHelpers;
has 'counter' => (
metaclass => 'Counter',
is => 'rw',
isa => 'Int',
default => sub { 0 },
provides => {
inc => 'inc_counter',
dec => 'dec_counter',
}
);
my $page = MyHomePage->new();
$page->inc_counter; # same as $page->counter($page->counter + 1);
$page->dec_counter; # same as $page->counter($page->counter - 1);
DESCRIPTION
This module provides a simple counter attribute, which can be incremented and decremeneted.
METHODS
- method_provider
- has_method_provider
- helper_type
PROVIDED METHODS
It is important to note that all those methods do in place modification of the value stored in the attribute.
- inc
-
Increments the value stored in this slot by 1.
- dec
-
Decrements the value stored in this slot by 1.
- reset
-
Resets the value stored in this slot to it's default value.
BUGS
All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT.
AUTHOR
Stevan Little <stevan@iinteractive.com>
COPYRIGHT AND LICENSE
Copyright 2007 by Infinity Interactive, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.