2 package MooseX::AttributeHelpers::MethodProvider::Number;
6 our $AUTHORITY = 'cpan:STEVAN';
15 foreach my $method (keys %ops)
17 my $s = $ops{$method};
18 __PACKAGE__->meta->alias_method($method, sub {
19 my ($attr, $reader, $writer) = @_;
20 return eval "sub { \$writer->(\$_[0], \$reader->(\$_[0]) $s \$_[1]) }";
25 my ($attr, $reader, $writer) = @_;
26 return sub { $writer->($_[0], CORE::abs($reader->($_[0]))) };
30 my ($attr, $reader, $writer) = @_;
31 return sub { $writer->($_[0], $_[1]) };
42 MooseX::AttributeHelpers::MethodProvider::Number
46 This is a role which provides the method generators for
47 L<MooseX::AttributeHelpers::Number>.
49 =head1 PROVIDED METHODS
51 It is important to note that all those methods do in place modification of the
52 value stored in the attribute. All methods but 'set' are plain mathematical
53 operators, as in $current_value = $current_value I<op>$argument, where I<op> is
54 the operator listed next to the method name.
68 =item B<abs>: |$val|, or $val = abs($value).
72 A way to set the value instead of 'setter' or 'is => "rw"'. This method is
73 provided for convenience.
79 All complex software has bugs lurking in it, and this module is no
80 exception. If you find a bug please either email me, or add the bug
85 Paul Driver E<lt>frowith@cpan.orgE<gt>
87 =head1 COPYRIGHT AND LICENSE
89 Copyright 2007-2008 by Infinity Interactive, Inc.
91 L<http://www.iinteractive.com>
93 This library is free software; you can redistribute it and/or modify
94 it under the same terms as Perl itself.