1MooseX::AttributeHelperUss:e:rNuCmobnetrr(i3b)uted PerlMDooocsuemXe:n:tAatttiroinbuteHelpers::Number(3)
2
3
4
6 MooseX::AttributeHelpers::Number
7
9 package Real;
10 use Moose;
11 use MooseX::AttributeHelpers;
12
13 has 'integer' => (
14 metaclass => 'Number',
15 is => 'ro',
16 isa => 'Int',
17 default => sub { 5 },
18 provides => {
19 set => 'set',
20 add => 'add',
21 sub => 'sub',
22 mul => 'mul',
23 div => 'div',
24 mod => 'mod',
25 abs => 'abs',
26 }
27 );
28
29 my $real = Real->new();
30 $real->add(5); # same as $real->integer($real->integer + 5);
31 $real->sub(2); # same as $real->integer($real->integer - 2);
32
34 This provides a simple numeric attribute, which supports most of the
35 basic math operations.
36
38 meta
39 helper_type
40 method_constructors
41
43 It is important to note that all those methods do in place modification
44 of the value stored in the attribute.
45
46 set ($value)
47 Alternate way to set the value.
48
49 add ($value)
50 Adds the current value of the attribute to $value.
51
52 sub ($value)
53 Subtracts the current value of the attribute to $value.
54
55 mul ($value)
56 Multiplies the current value of the attribute to $value.
57
58 div ($value)
59 Divides the current value of the attribute to $value.
60
61 mod ($value)
62 Modulus the current value of the attribute to $value.
63
64 abs Sets the current value of the attribute to its absolute value.
65
67 All complex software has bugs lurking in it, and this module is no
68 exception. If you find a bug please either email me, or add the bug to
69 cpan-RT.
70
72 Robert Boone
73
75 Copyright 2007-2009 by Infinity Interactive, Inc.
76
77 <http://www.iinteractive.com>
78
79 This library is free software; you can redistribute it and/or modify it
80 under the same terms as Perl itself.
81
82
83
84perl v5.12.0 2010-01-01MooseX::AttributeHelpers::Number(3)