Bump version to 1.9900 for new version numbering scheme
[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
bb8ef151 4our $VERSION = '1.9900';
e3c07b19 5$VERSION = eval $VERSION;
6our $AUTHORITY = 'cpan:STEVAN';
7
c466e58f 8with 'Moose::Meta::Attribute::Native::Trait';
e3c07b19 9
2e069f5a 10sub _helper_type { 'Num' }
e3c07b19 11
e3c07b19 12no Moose::Role;
13
e3c07b19 141;
15
16=pod
17
18=head1 NAME
19
2420461c 20Moose::Meta::Attribute::Native::Trait::Number - Helper trait for Num attributes
e3c07b19 21
22=head1 SYNOPSIS
23
24 package Real;
25 use Moose;
e3c07b19 26
27 has 'integer' => (
e132fd56 28 traits => ['Number'],
29 is => 'ro',
30 isa => 'Num',
31 default => 5,
32 handles => {
e3c07b19 33 set => 'set',
34 add => 'add',
35 sub => 'sub',
36 mul => 'mul',
37 div => 'div',
38 mod => 'mod',
39 abs => 'abs',
9610c1d2 40 },
e3c07b19 41 );
42
43 my $real = Real->new();
e132fd56 44 $real->add(5); # same as $real->integer($real->integer + 5);
45 $real->sub(2); # same as $real->integer($real->integer - 2);
e3c07b19 46
47=head1 DESCRIPTION
48
7795e4de 49This trait provides native delegation methods for numbers. All of the
50operations correspond to arithmetic operations like addition or
51multiplication.
52
53=head1 DEFAULT TYPE
54
55If you don't provide an C<isa> value for your attribute, it will default to
56C<Num>.
e3c07b19 57
e3c07b19 58=head1 PROVIDED METHODS
59
7795e4de 60All of these methods modify the attribute's value in place. All methods return
61the new value.
e3c07b19 62
63=over 4
64
e132fd56 65=item * B<add($value)>
e3c07b19 66
7795e4de 67Adds the current value of the attribute to C<$value>.
e3c07b19 68
e132fd56 69=item * B<sub($value)>
e3c07b19 70
7795e4de 71Subtracts C<$value> from the current value of the attribute.
e3c07b19 72
e132fd56 73=item * B<mul($value)>
e3c07b19 74
7795e4de 75Multiplies the current value of the attribute by C<$value>.
e3c07b19 76
e132fd56 77=item * B<div($value)>
e3c07b19 78
7795e4de 79Divides the current value of the attribute by C<$value>.
e3c07b19 80
e132fd56 81=item * B<mod($value)>
e3c07b19 82
7795e4de 83Returns the current value of the attribute modulo C<$value>.
e3c07b19 84
e132fd56 85=item * B<abs>
e3c07b19 86
7795e4de 87Sets the current value of the attribute to its absolute value.
ace7cdf9 88
89=back
90
e3c07b19 91=head1 BUGS
92
d4048ef3 93See L<Moose/BUGS> for details on reporting bugs.
e3c07b19 94
95=head1 AUTHOR
96
97Robert Boone
98
99=head1 COPYRIGHT AND LICENSE
100
101Copyright 2007-2009 by Infinity Interactive, Inc.
102
103L<http://www.iinteractive.com>
104
105This library is free software; you can redistribute it and/or modify
106it under the same terms as Perl itself.
107
108=cut