adding Role/Class support for method providers
[gitmo/MooseX-AttributeHelpers.git] / lib / MooseX / AttributeHelpers / Counter.pm
CommitLineData
22d869ff 1
2package MooseX::AttributeHelpers::Counter;
3use Moose;
22d869ff 4
5our $VERSION = '0.01';
6our $AUTHORITY = 'cpan:STEVAN';
7
8e3fab6d 8use MooseX::AttributeHelpers::MethodProvider::Counter;
d26633fc 9
8e3fab6d 10extends 'MooseX::AttributeHelpers::Base';
8ba40fb0 11
8e3fab6d 12has '+method_provider' => (
13 default => 'MooseX::AttributeHelpers::MethodProvider::Counter'
d26633fc 14);
8e3fab6d 15
16sub helper_type { 'Num' }
22d869ff 17
22d869ff 18no Moose;
22d869ff 19
20# register the alias ...
21package Moose::Meta::Attribute::Custom::Counter;
22sub register_implementation { 'MooseX::AttributeHelpers::Counter' }
23
241;
25
26__END__
27
28=pod
29
30=head1 NAME
31
32MooseX::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
60All complex software has bugs lurking in it, and this module is no
61exception. If you find a bug please either email me, or add the bug
62to cpan-RT.
63
64=head1 AUTHOR
65
66Stevan Little E<lt>stevan@iinteractive.comE<gt>
67
68=head1 COPYRIGHT AND LICENSE
69
70Copyright 2007 by Infinity Interactive, Inc.
71
72L<http://www.iinteractive.com>
73
74This library is free software; you can redistribute it and/or modify
75it under the same terms as Perl itself.
76
77=cut