1Moose::Meta::Attribute:U:sNeartiCvoen:tM:roTiorbsaueit:te::dM:eNPtueamr:bl:eArDt(ot3cr)uimbeunttea:t:iNoantive::Trait::Number(3)
2
3
4
6 Moose::Meta::Attribute::Native::Trait::Number - Helper trait for Num
7 attributes
8
10 version 2.2014
11
13 package Real;
14 use Moose;
15
16 has 'integer' => (
17 traits => ['Number'],
18 is => 'ro',
19 isa => 'Num',
20 default => 5,
21 handles => {
22 set => 'set',
23 add => 'add',
24 sub => 'sub',
25 mul => 'mul',
26 div => 'div',
27 mod => 'mod',
28 abs => 'abs',
29 },
30 );
31
32 my $real = Real->new();
33 $real->add(5); # same as $real->integer($real->integer + 5);
34 $real->sub(2); # same as $real->integer($real->integer - 2);
35
37 This trait provides native delegation methods for numbers. All of the
38 operations correspond to arithmetic operations like addition or
39 multiplication.
40
42 If you don't provide an "isa" value for your attribute, it will default
43 to "Num".
44
46 All of these methods modify the attribute's value in place. All methods
47 return the new value.
48
49 • add($value)
50
51 Adds the current value of the attribute to $value.
52
53 • sub($value)
54
55 Subtracts $value from the current value of the attribute.
56
57 • mul($value)
58
59 Multiplies the current value of the attribute by $value.
60
61 • div($value)
62
63 Divides the current value of the attribute by $value.
64
65 • mod($value)
66
67 Returns the current value of the attribute modulo $value.
68
69 • abs
70
71 Sets the current value of the attribute to its absolute value.
72
74 See "BUGS" in Moose for details on reporting bugs.
75
77 • Stevan Little <stevan@cpan.org>
78
79 • Dave Rolsky <autarch@urth.org>
80
81 • Jesse Luehrs <doy@cpan.org>
82
83 • Shawn M Moore <sartak@cpan.org>
84
85 • יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
86
87 • Karen Etheridge <ether@cpan.org>
88
89 • Florian Ragwitz <rafl@debian.org>
90
91 • Hans Dieter Pearcey <hdp@cpan.org>
92
93 • Chris Prather <chris@prather.org>
94
95 • Matt S Trout <mstrout@cpan.org>
96
98 This software is copyright (c) 2006 by Infinity Interactive, Inc.
99
100 This is free software; you can redistribute it and/or modify it under
101 the same terms as the Perl 5 programming language system itself.
102
103
104
105perl v5.32.1 Moos2e0:2:1M-e0t1a-:2:7Attribute::Native::Trait::Number(3)