Bump to 0.21
[gitmo/MooseX-AttributeHelpers.git] / lib / MooseX / AttributeHelpers / Number.pm
CommitLineData
565fe238 1package MooseX::AttributeHelpers::Number;
2use Moose;
565fe238 3
9807aa66 4our $VERSION = '0.21';
38430345 5$VERSION = eval $VERSION;
565fe238 6our $AUTHORITY = 'cpan:STEVAN';
7
393f5679 8extends 'Moose::Meta::Attribute';
9with 'MooseX::AttributeHelpers::Trait::Number';
565fe238 10
565fe238 11no Moose;
565fe238 12
13# register the alias ...
0f31cc28 14package # hide me from search.cpan.org
15 Moose::Meta::Attribute::Custom::Number;
565fe238 16sub register_implementation { 'MooseX::AttributeHelpers::Number' }
17
181;
19
20=pod
21
22=head1 NAME
23
24MooseX::AttributeHelpers::Number
25
26=head1 SYNOPSIS
27
28 package Real;
5431dff2 29 use Moose;
30 use MooseX::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 );
565fe238 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
5431dff2 54This provides a simple numeric attribute, which supports most of the
55basic math operations.
56
565fe238 57=head1 METHODS
58
5431dff2 59=over 4
60
b91f57af 61=item B<meta>
62
5431dff2 63=item B<helper_type>
64
65=item B<method_constructors>
66
67=back
68
c91a1347 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
565fe238 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
8c651099 114Robert Boone
565fe238 115
116=head1 COPYRIGHT AND LICENSE
117
9c5d164e 118Copyright 2007-2009 by Infinity Interactive, Inc.
565fe238 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
ae2c330e 125=cut