2 package MooseX::AttributeHelpers::MethodProvider::Number;
6 our $AUTHORITY = 'cpan:STEVAN';
16 foreach my $method (keys %ops)
18 my $s = $ops{$method};
19 __PACKAGE__->meta->alias_method($method, sub {
20 my ($attr, $reader, $writer) = @_;
21 return eval "sub { \$writer->(\$_[0], \$reader->(\$_[0]) $s \$_[1]) }";
26 my ($attr, $reader, $writer) = @_;
27 return sub { $writer->($_[0], CORE::abs($reader->($_[0]))) };
31 my ($attr, $reader, $writer) = @_;
32 return sub { $writer->($_[0], $_[1]) };
43 MooseX::AttributeHelpers::MethodProvider::Number
47 This is a role which provides the method generators for
48 L<MooseX::AttributeHelpers::Number>.
50 =head1 PROVIDED METHODS
52 All methods but 'set' are plain mathematical operators, as in
53 C<$current_value = $current_value OP $argument>
54 where OP is 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.