| File | /usr/local/lib/perl5/site_perl/5.10.1/MooseX/AttributeHelpers/Number.pm |
| Statements Executed | 12 |
| Statement Execution Time | 177µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 15µs | 2.42ms | MooseX::AttributeHelpers::Number::BEGIN@2 |
| 1 | 1 | 1 | 8µs | 104µs | MooseX::AttributeHelpers::Number::BEGIN@11 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Attribute::Custom::Number::register_implementation |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package MooseX::AttributeHelpers::Number; | ||||
| 2 | 3 | 63µs | 2 | 4.83ms | # spent 2.42ms (15µs+2.41) within MooseX::AttributeHelpers::Number::BEGIN@2 which was called
# once (15µs+2.41ms) by MooseX::AttributeHelpers::BEGIN@24 at line 2 # spent 2.42ms making 1 call to MooseX::AttributeHelpers::Number::BEGIN@2
# spent 2.41ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:389] |
| 3 | |||||
| 4 | 1 | 600ns | our $VERSION = '0.23'; | ||
| 5 | 1 | 16µs | $VERSION = eval $VERSION; | ||
| 6 | 1 | 300ns | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 7 | |||||
| 8 | 1 | 2µs | 1 | 377µs | extends 'Moose::Meta::Attribute'; # spent 377µs making 1 call to Moose::extends |
| 9 | 1 | 2µs | 1 | 7.01ms | with 'MooseX::AttributeHelpers::Trait::Number'; # spent 7.01ms making 1 call to Moose::with |
| 10 | |||||
| 11 | 3 | 76µs | 2 | 199µs | # spent 104µs (8+96) within MooseX::AttributeHelpers::Number::BEGIN@11 which was called
# once (8µs+96µs) by MooseX::AttributeHelpers::BEGIN@24 at line 11 # spent 104µs making 1 call to MooseX::AttributeHelpers::Number::BEGIN@11
# spent 96µs making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:478] |
| 12 | |||||
| 13 | # register the alias ... | ||||
| 14 | package # hide me from search.cpan.org | ||||
| 15 | Moose::Meta::Attribute::Custom::Number; | ||||
| 16 | sub register_implementation { 'MooseX::AttributeHelpers::Number' } | ||||
| 17 | |||||
| 18 | 1 | 18µs | 1; | ||
| 19 | |||||
| 20 | =pod | ||||
| 21 | |||||
| 22 | =head1 NAME | ||||
| 23 | |||||
| 24 | MooseX::AttributeHelpers::Number | ||||
| 25 | |||||
| 26 | =head1 SYNOPSIS | ||||
| 27 | |||||
| 28 | package Real; | ||||
| 29 | use Moose; | ||||
| 30 | use MooseX::AttributeHelpers; | ||||
| 31 | |||||
| 32 | has 'integer' => ( | ||||
| 33 | metaclass => 'Number', | ||||
| 34 | is => 'ro', | ||||
| 35 | isa => 'Int', | ||||
| 36 | default => sub { 5 }, | ||||
| 37 | provides => { | ||||
| 38 | set => 'set', | ||||
| 39 | add => 'add', | ||||
| 40 | sub => 'sub', | ||||
| 41 | mul => 'mul', | ||||
| 42 | div => 'div', | ||||
| 43 | mod => 'mod', | ||||
| 44 | abs => 'abs', | ||||
| 45 | } | ||||
| 46 | ); | ||||
| 47 | |||||
| 48 | my $real = Real->new(); | ||||
| 49 | $real->add(5); # same as $real->integer($real->integer + 5); | ||||
| 50 | $real->sub(2); # same as $real->integer($real->integer - 2); | ||||
| 51 | |||||
| 52 | =head1 DESCRIPTION | ||||
| 53 | |||||
| 54 | This provides a simple numeric attribute, which supports most of the | ||||
| 55 | basic math operations. | ||||
| 56 | |||||
| 57 | =head1 METHODS | ||||
| 58 | |||||
| 59 | =over 4 | ||||
| 60 | |||||
| 61 | =item B<meta> | ||||
| 62 | |||||
| 63 | =item B<helper_type> | ||||
| 64 | |||||
| 65 | =item B<method_constructors> | ||||
| 66 | |||||
| 67 | =back | ||||
| 68 | |||||
| 69 | =head1 PROVIDED METHODS | ||||
| 70 | |||||
| 71 | It is important to note that all those methods do in place | ||||
| 72 | modification of the value stored in the attribute. | ||||
| 73 | |||||
| 74 | =over 4 | ||||
| 75 | |||||
| 76 | =item I<set ($value)> | ||||
| 77 | |||||
| 78 | Alternate way to set the value. | ||||
| 79 | |||||
| 80 | =item I<add ($value)> | ||||
| 81 | |||||
| 82 | Adds the current value of the attribute to C<$value>. | ||||
| 83 | |||||
| 84 | =item I<sub ($value)> | ||||
| 85 | |||||
| 86 | Subtracts the current value of the attribute to C<$value>. | ||||
| 87 | |||||
| 88 | =item I<mul ($value)> | ||||
| 89 | |||||
| 90 | Multiplies the current value of the attribute to C<$value>. | ||||
| 91 | |||||
| 92 | =item I<div ($value)> | ||||
| 93 | |||||
| 94 | Divides the current value of the attribute to C<$value>. | ||||
| 95 | |||||
| 96 | =item I<mod ($value)> | ||||
| 97 | |||||
| 98 | Modulus the current value of the attribute to C<$value>. | ||||
| 99 | |||||
| 100 | =item I<abs> | ||||
| 101 | |||||
| 102 | Sets the current value of the attribute to its absolute value. | ||||
| 103 | |||||
| 104 | =back | ||||
| 105 | |||||
| 106 | =head1 BUGS | ||||
| 107 | |||||
| 108 | All complex software has bugs lurking in it, and this module is no | ||||
| 109 | exception. If you find a bug please either email me, or add the bug | ||||
| 110 | to cpan-RT. | ||||
| 111 | |||||
| 112 | =head1 AUTHOR | ||||
| 113 | |||||
| 114 | Robert Boone | ||||
| 115 | |||||
| 116 | =head1 COPYRIGHT AND LICENSE | ||||
| 117 | |||||
| 118 | Copyright 2007-2009 by Infinity Interactive, Inc. | ||||
| 119 | |||||
| 120 | L<http://www.iinteractive.com> | ||||
| 121 | |||||
| 122 | This library is free software; you can redistribute it and/or modify | ||||
| 123 | it under the same terms as Perl itself. | ||||
| 124 | |||||
| 125 | =cut |