0f196ad96b98bb63b8aa6306e1b3857346b319b3
[gitmo/MooseX-AttributeHelpers.git] / lib / MooseX / AttributeHelpers / Counter.pm
1
2 package MooseX::AttributeHelpers::Counter;
3 use Moose;
4
5 our $VERSION   = '0.01';
6 our $AUTHORITY = 'cpan:STEVAN';
7
8 use MooseX::AttributeHelpers::MethodProvider::Counter;
9
10 extends 'MooseX::AttributeHelpers::Base';
11
12 has '+method_provider' => (
13     default => 'MooseX::AttributeHelpers::MethodProvider::Counter'
14 );
15
16 sub helper_type { 'Num' }
17     
18 no Moose;
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',
46           dec => 'dec_counter',          
47       }
48   );
49
50   my $page = MyHomePage->new();
51   $page->inc_counter; # same as $page->counter($page->counter + 1);
52   $page->dec_counter; # same as $page->counter($page->counter - 1);  
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