1MooseX::AttributeHelperUss:e:rTrCaointt:r:iNbuuMmtobeoedsre(PX3e:pr:mlA)tDtorciubmuetnetHaetlipoenrs::Trait::Number(3pm)
2
3
4
6 MooseX::AttributeHelpers::Trait::Number
7
9 version 0.25
10
12 package Real;
13 use Moose;
14 use MooseX::AttributeHelpers;
15
16 has 'integer' => (
17 metaclass => 'Number',
18 is => 'ro',
19 isa => 'Int',
20 default => sub { 5 },
21 provides => {
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 provides a simple numeric attribute, which supports most of the
38 basic math operations.
39
41 meta
42 helper_type
43 method_constructors
44
46 It is important to note that all those methods do in place modification
47 of the value stored in the attribute.
48
49 set ($value)
50 Alternate way to set the value.
51
52 add ($value)
53 Adds the current value of the attribute to $value.
54
55 sub ($value)
56 Subtracts the current value of the attribute to $value.
57
58 mul ($value)
59 Multiplies the current value of the attribute to $value.
60
61 div ($value)
62 Divides the current value of the attribute to $value.
63
64 mod ($value)
65 Modulus the current value of the attribute to $value.
66
67 abs Sets the current value of the attribute to its absolute value.
68
70 Bugs may be submitted through the RT bug tracker
71 <https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-
72 AttributeHelpers> (or bug-MooseX-AttributeHelpers@rt.cpan.org
73 <mailto:bug-MooseX-AttributeHelpers@rt.cpan.org>).
74
75 There is also a mailing list available for users of this distribution,
76 at <http://lists.perl.org/list/moose.html>.
77
78 There is also an irc channel available for users of this distribution,
79 at "#moose" on "irc.perl.org" <irc://irc.perl.org/#moose>.
80
82 Stevan Little <stevan@iinteractive.com>
83
84 Robert Boone
85
87 This software is copyright (c) 2007 by Stevan Little and Infinity
88 Interactive, Inc.
89
90 This is free software; you can redistribute it and/or modify it under
91 the same terms as the Perl 5 programming language system itself.
92
93
94
95perl v5.28.1 2M0o1o6s-e0X2:-:1A6ttributeHelpers::Trait::Number(3pm)