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