Commit | Line | Data |
22d869ff |
1 | |
2 | package MooseX::AttributeHelpers::Counter; |
3 | use Moose; |
22d869ff |
4 | |
5 | our $VERSION = '0.01'; |
6 | our $AUTHORITY = 'cpan:STEVAN'; |
7 | |
8e3fab6d |
8 | use MooseX::AttributeHelpers::MethodProvider::Counter; |
d26633fc |
9 | |
8e3fab6d |
10 | extends 'MooseX::AttributeHelpers::Base'; |
8ba40fb0 |
11 | |
8e3fab6d |
12 | has '+method_provider' => ( |
13 | default => 'MooseX::AttributeHelpers::MethodProvider::Counter' |
d26633fc |
14 | ); |
8e3fab6d |
15 | |
16 | sub helper_type { 'Num' } |
22d869ff |
17 | |
22d869ff |
18 | no Moose; |
22d869ff |
19 | |
20 | # register the alias ... |
21 | package Moose::Meta::Attribute::Custom::Counter; |
22 | sub register_implementation { 'MooseX::AttributeHelpers::Counter' } |
23 | |
24 | 1; |
25 | |
26 | __END__ |
27 | |
28 | =pod |
29 | |
30 | =head1 NAME |
31 | |
32 | MooseX::AttributeHelpers::Counter |
33 | |
34 | =head1 SYNOPSIS |
35 | |
36 | package MyHomePage; |
37 | use Moose; |
38 | |
39 | has 'counter' => ( |
40 | metaclass => 'Counter', |
41 | is => 'rw', |
42 | isa => 'Int', |
43 | default => sub { 0 }, |
44 | provides => { |
45 | inc => 'inc_counter', |
21c7045b |
46 | dec => 'dec_counter', |
22d869ff |
47 | } |
48 | ); |
49 | |
50 | my $page = MyHomePage->new(); |
51 | $page->inc_counter; # same as $page->counter($page->counter + 1); |
21c7045b |
52 | $page->dec_counter; # same as $page->counter($page->counter - 1); |
22d869ff |
53 | |
54 | =head1 DESCRIPTION |
55 | |
56 | =head1 METHODS |
57 | |
58 | =head1 BUGS |
59 | |
60 | All complex software has bugs lurking in it, and this module is no |
61 | exception. If you find a bug please either email me, or add the bug |
62 | to cpan-RT. |
63 | |
64 | =head1 AUTHOR |
65 | |
66 | Stevan Little E<lt>stevan@iinteractive.comE<gt> |
67 | |
68 | =head1 COPYRIGHT AND LICENSE |
69 | |
70 | Copyright 2007 by Infinity Interactive, Inc. |
71 | |
72 | L<http://www.iinteractive.com> |
73 | |
74 | This library is free software; you can redistribute it and/or modify |
75 | it under the same terms as Perl itself. |
76 | |
77 | =cut |