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