1MooseX::AttributeHelperUss:e:rTrCaointt:r:iCbouutMneotdoesrPe(eX3r:)l:ADtotcruimbeuntteaHteilopners::Trait::Counter(3)
2
3
4
6 MooseX::AttributeHelpers::Counter
7
9 package MyHomePage;
10 use Moose;
11 use MooseX::AttributeHelpers;
12
13 has 'counter' => (
14 metaclass => 'Counter',
15 is => 'ro',
16 isa => 'Num',
17 default => sub { 0 },
18 provides => {
19 inc => 'inc_counter',
20 dec => 'dec_counter',
21 reset => 'reset_counter',
22 }
23 );
24
25 my $page = MyHomePage->new();
26 $page->inc_counter; # same as $page->counter($page->counter + 1);
27 $page->dec_counter; # same as $page->counter($page->counter - 1);
28
30 This module provides a simple counter attribute, which can be
31 incremented and decremeneted.
32
33 If your attribute definition does not include any of is, isa, default
34 or provides but does use the "Counter" metaclass, then this module
35 applies defaults as in the "SYNOPSIS" above. This allows for a very
36 basic counter definition:
37
38 has 'foo' => (metaclass => 'Counter');
39 $obj->inc_foo;
40
42 meta
43 method_provider
44 has_method_provider
45 helper_type
46 process_options_for_provides
47 Run before its superclass method.
48
49 check_provides_values
50 Run after its superclass method.
51
53 It is important to note that all those methods do in place modification
54 of the value stored in the attribute.
55
56 set Set the counter to the specified value.
57
58 inc Increments the value stored in this slot by 1. Providing an
59 argument will cause the counter to be increased by specified
60 amount.
61
62 dec Decrements the value stored in this slot by 1. Providing an
63 argument will cause the counter to be increased by specified
64 amount.
65
66 reset
67 Resets the value stored in this slot to it's default value.
68
70 All complex software has bugs lurking in it, and this module is no
71 exception. If you find a bug please either email me, or add the bug to
72 cpan-RT.
73
75 Stevan Little <stevan@iinteractive.com>
76
78 Copyright 2007-2009 by Infinity Interactive, Inc.
79
80 <http://www.iinteractive.com>
81
82 This library is free software; you can redistribute it and/or modify it
83 under the same terms as Perl itself.
84
85
86
87perl v5.12.0 20M1o0o-s0e1X-:0:1AttributeHelpers::Trait::Counter(3)