0.01
[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   use MooseX::AttributeHelpers;
39   
40   has 'counter' => (
41       metaclass => 'Counter',
42       is        => 'rw',
43       isa       => 'Int',
44       default   => sub { 0 },
45       provides  => {
46           inc => 'inc_counter',
47           dec => 'dec_counter',          
48       }
49   );
50
51   my $page = MyHomePage->new();
52   $page->inc_counter; # same as $page->counter($page->counter + 1);
53   $page->dec_counter; # same as $page->counter($page->counter - 1);  
54   
55 =head1 DESCRIPTION
56
57 This module provides a simple counter attribute, which can be 
58 incremented and decremeneted. 
59
60 =head1 METHODS
61
62 =over 4
63
64 =item B<method_provider>
65
66 =item B<has_method_provider>
67
68 =item B<helper_type>
69
70 =back
71
72 =head1 BUGS
73
74 All complex software has bugs lurking in it, and this module is no 
75 exception. If you find a bug please either email me, or add the bug
76 to cpan-RT.
77
78 =head1 AUTHOR
79
80 Stevan Little E<lt>stevan@iinteractive.comE<gt>
81
82 =head1 COPYRIGHT AND LICENSE
83
84 Copyright 2007 by Infinity Interactive, Inc.
85
86 L<http://www.iinteractive.com>
87
88 This library is free software; you can redistribute it and/or modify
89 it under the same terms as Perl itself.
90
91 =cut