fix up some abstracts
[gitmo/Moose.git] / lib / Moose / Meta / Attribute / Native / Trait / Number.pm
CommitLineData
c466e58f 1package Moose::Meta::Attribute::Native::Trait::Number;
e3c07b19 2use Moose::Role;
3
c466e58f 4with 'Moose::Meta::Attribute::Native::Trait';
e3c07b19 5
2e069f5a 6sub _helper_type { 'Num' }
e3c07b19 7
e3c07b19 8no Moose::Role;
9
e3c07b19 101;
11
e818d161 12# ABSTRACT: Helper trait for Num attributes
13
14__END__
15
e3c07b19 16=pod
17
e3c07b19 18=head1 SYNOPSIS
19
20 package Real;
21 use Moose;
e3c07b19 22
23 has 'integer' => (
e132fd56 24 traits => ['Number'],
25 is => 'ro',
26 isa => 'Num',
27 default => 5,
28 handles => {
e3c07b19 29 set => 'set',
30 add => 'add',
31 sub => 'sub',
32 mul => 'mul',
33 div => 'div',
34 mod => 'mod',
35 abs => 'abs',
9610c1d2 36 },
e3c07b19 37 );
38
39 my $real = Real->new();
e132fd56 40 $real->add(5); # same as $real->integer($real->integer + 5);
41 $real->sub(2); # same as $real->integer($real->integer - 2);
e3c07b19 42
43=head1 DESCRIPTION
44
7795e4de 45This trait provides native delegation methods for numbers. All of the
46operations correspond to arithmetic operations like addition or
47multiplication.
48
49=head1 DEFAULT TYPE
50
51If you don't provide an C<isa> value for your attribute, it will default to
52C<Num>.
e3c07b19 53
e3c07b19 54=head1 PROVIDED METHODS
55
7795e4de 56All of these methods modify the attribute's value in place. All methods return
57the new value.
e3c07b19 58
59=over 4
60
e132fd56 61=item * B<add($value)>
e3c07b19 62
7795e4de 63Adds the current value of the attribute to C<$value>.
e3c07b19 64
e132fd56 65=item * B<sub($value)>
e3c07b19 66
7795e4de 67Subtracts C<$value> from the current value of the attribute.
e3c07b19 68
e132fd56 69=item * B<mul($value)>
e3c07b19 70
7795e4de 71Multiplies the current value of the attribute by C<$value>.
e3c07b19 72
e132fd56 73=item * B<div($value)>
e3c07b19 74
7795e4de 75Divides the current value of the attribute by C<$value>.
e3c07b19 76
e132fd56 77=item * B<mod($value)>
e3c07b19 78
7795e4de 79Returns the current value of the attribute modulo C<$value>.
e3c07b19 80
e132fd56 81=item * B<abs>
e3c07b19 82
7795e4de 83Sets the current value of the attribute to its absolute value.
ace7cdf9 84
85=back
86
e3c07b19 87=head1 BUGS
88
d4048ef3 89See L<Moose/BUGS> for details on reporting bugs.
e3c07b19 90
e3c07b19 91=cut