File Coverage

blib/lib/MooseX/AttributeHelpers/MethodProvider/Counter.pm
Criterion Covered Total %
statement 15 15 100.0
branch 4 4 100.0
condition n/a
subroutine 10 10 100.0
pod 4 4 100.0
total 33 33 100.0


line stmt bran cond sub pod time code
1             package MooseX::AttributeHelpers::MethodProvider::Counter;
2 22     22   93 use Moose::Role;
  22         33  
  22         125  
3              
4             our $VERSION = '0.25';
5              
6             sub reset : method {
7 4     4 1 22 my ($attr, $reader, $writer) = @_;
8 4     3   31 return sub { $writer->($_[0], $attr->default($_[0])) };
  3     8   2312  
9             }
10              
11             sub set : method {
12 3     3 1 18 my ($attr, $reader, $writer, $value) = @_;
13 3     2   30 return sub { $writer->($_[0], $_[1]) };
  2         1559  
14             }
15              
16             sub inc {
17 5     7 1 34 my ($attr, $reader, $writer) = @_;
18 5 100   16   51 return sub { $writer->($_[0], $reader->($_[0]) + (defined($_[1]) ? $_[1] : 1) ) };
  16         20191  
19             }
20              
21             sub dec {
22 5     13 1 26 my ($attr, $reader, $writer) = @_;
23 5 100   13   32 return sub { $writer->($_[0], $reader->($_[0]) - (defined($_[1]) ? $_[1] : 1) ) };
  13         11697  
24             }
25              
26             1;
27              
28             __END__
29              
30             =pod
31              
32             =encoding UTF-8
33              
34             =head1 NAME
35              
36             MooseX::AttributeHelpers::MethodProvider::Counter
37              
38             =head1 VERSION
39              
40             version 0.25
41              
42             =head1 DESCRIPTION
43              
44             This is a role which provides the method generators for
45             L<MooseX::AttributeHelpers::Counter>.
46              
47             =head1 METHODS
48              
49             =over 4
50              
51             =item B<meta>
52              
53             =back
54              
55             =head1 PROVIDED METHODS
56              
57             =over 4
58              
59             =item B<set>
60              
61             =item B<inc>
62              
63             =item B<dec>
64              
65             =item B<reset>
66              
67             =back
68              
69             =head1 SUPPORT
70              
71             Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-AttributeHelpers>
72             (or L<bug-MooseX-AttributeHelpers@rt.cpan.org|mailto:bug-MooseX-AttributeHelpers@rt.cpan.org>).
73              
74             There is also a mailing list available for users of this distribution, at
75             L<http://lists.perl.org/list/moose.html>.
76              
77             There is also an irc channel available for users of this distribution, at
78             L<C<#moose> on C<irc.perl.org>|irc://irc.perl.org/#moose>.
79              
80             =head1 AUTHOR
81              
82             Stevan Little <stevan@iinteractive.com>
83              
84             =head1 COPYRIGHT AND LICENSE
85              
86             This software is copyright (c) 2007 by Stevan Little and Infinity Interactive, Inc.
87              
88             This is free software; you can redistribute it and/or modify it under
89             the same terms as the Perl 5 programming language system itself.
90              
91             =cut