start replacing provides/curries with handles
[gitmo/Moose.git] / lib / Moose / AttributeHelpers / Number.pm
CommitLineData
e3c07b19 1package Moose::AttributeHelpers::Number;
2use Moose;
3
4our $VERSION = '0.19';
5$VERSION = eval $VERSION;
6our $AUTHORITY = 'cpan:STEVAN';
7
8extends 'Moose::Meta::Attribute';
9with 'Moose::AttributeHelpers::Trait::Number';
10
11no Moose;
12
13# register the alias ...
14package # hide me from search.cpan.org
15 Moose::Meta::Attribute::Custom::Number;
16sub register_implementation { 'Moose::AttributeHelpers::Number' }
17
181;
19
20=pod
21
22=head1 NAME
23
24Moose::AttributeHelpers::Number
25
26=head1 SYNOPSIS
27
28 package Real;
29 use Moose;
30 use Moose::AttributeHelpers;
31
32 has 'integer' => (
33 metaclass => 'Number',
34 is => 'ro',
35 isa => 'Int',
36 default => sub { 5 },
37 provides => {
38 set => 'set',
39 add => 'add',
40 sub => 'sub',
41 mul => 'mul',
42 div => 'div',
43 mod => 'mod',
44 abs => 'abs',
45 }
46 );
47
48 my $real = Real->new();
49 $real->add(5); # same as $real->integer($real->integer + 5);
50 $real->sub(2); # same as $real->integer($real->integer - 2);
51
52=head1 DESCRIPTION
53
54This provides a simple numeric attribute, which supports most of the
55basic math operations.
56
57=head1 METHODS
58
59=over 4
60
61=item B<meta>
62
63=item B<helper_type>
64
65=item B<method_constructors>
66
67=back
68
69=head1 PROVIDED METHODS
70
71It is important to note that all those methods do in place
72modification of the value stored in the attribute.
73
74=over 4
75
76=item I<set ($value)>
77
78Alternate way to set the value.
79
80=item I<add ($value)>
81
82Adds the current value of the attribute to C<$value>.
83
84=item I<sub ($value)>
85
86Subtracts the current value of the attribute to C<$value>.
87
88=item I<mul ($value)>
89
90Multiplies the current value of the attribute to C<$value>.
91
92=item I<div ($value)>
93
94Divides the current value of the attribute to C<$value>.
95
96=item I<mod ($value)>
97
98Modulus the current value of the attribute to C<$value>.
99
100=item I<abs>
101
102Sets the current value of the attribute to its absolute value.
103
104=back
105
106=head1 BUGS
107
108All complex software has bugs lurking in it, and this module is no
109exception. If you find a bug please either email me, or add the bug
110to cpan-RT.
111
112=head1 AUTHOR
113
114Robert Boone
115
116=head1 COPYRIGHT AND LICENSE
117
118Copyright 2007-2009 by Infinity Interactive, Inc.
119
120L<http://www.iinteractive.com>
121
122This library is free software; you can redistribute it and/or modify
123it under the same terms as Perl itself.
124
125=cut