| Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Meta/Method/Augmented.pm |
| Statements | Executed 10 statements in 173µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 12µs | 13µs | Moose::Meta::Method::Augmented::BEGIN@4 |
| 1 | 1 | 1 | 4µs | 8µs | Moose::Meta::Method::Augmented::BEGIN@5 |
| 1 | 1 | 1 | 4µs | 81µs | Moose::Meta::Method::Augmented::BEGIN@9 |
| 1 | 1 | 1 | 4µs | 18µs | Moose::Meta::Method::Augmented::BEGIN@7 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Augmented::__ANON__[:49] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Augmented::new |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Meta::Method::Augmented; | ||||
| 2 | 1 | 300ns | our $VERSION = '2.1605'; | ||
| 3 | |||||
| 4 | 2 | 15µs | 2 | 14µs | # spent 13µs (12+1) within Moose::Meta::Method::Augmented::BEGIN@4 which was called:
# once (12µs+1µs) by Moose::Meta::Class::BEGIN@14 at line 4 # spent 13µs making 1 call to Moose::Meta::Method::Augmented::BEGIN@4
# spent 2µs making 1 call to strict::import |
| 5 | 2 | 13µs | 2 | 11µs | # spent 8µs (4+3) within Moose::Meta::Method::Augmented::BEGIN@5 which was called:
# once (4µs+3µs) by Moose::Meta::Class::BEGIN@14 at line 5 # spent 8µs making 1 call to Moose::Meta::Method::Augmented::BEGIN@5
# spent 3µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 2 | 17µs | 2 | 31µs | # spent 18µs (4+14) within Moose::Meta::Method::Augmented::BEGIN@7 which was called:
# once (4µs+14µs) by Moose::Meta::Class::BEGIN@14 at line 7 # spent 18µs making 1 call to Moose::Meta::Method::Augmented::BEGIN@7
# spent 14µs making 1 call to parent::import |
| 8 | |||||
| 9 | 2 | 126µs | 2 | 157µs | # spent 81µs (4+77) within Moose::Meta::Method::Augmented::BEGIN@9 which was called:
# once (4µs+77µs) by Moose::Meta::Class::BEGIN@14 at line 9 # spent 81µs making 1 call to Moose::Meta::Method::Augmented::BEGIN@9
# spent 77µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
| 10 | |||||
| 11 | sub new { | ||||
| 12 | my ( $class, %args ) = @_; | ||||
| 13 | |||||
| 14 | # the package can be overridden by roles | ||||
| 15 | # it is really more like body's compilation stash | ||||
| 16 | # this is where we need to override the definition of super() so that the | ||||
| 17 | # body of the code can call the right overridden version | ||||
| 18 | my $name = $args{name}; | ||||
| 19 | my $meta = $args{class}; | ||||
| 20 | |||||
| 21 | my $super = $meta->find_next_method_by_name($name); | ||||
| 22 | |||||
| 23 | (defined $super) | ||||
| 24 | || throw_exception( CannotAugmentNoSuperMethod => params => \%args, | ||||
| 25 | class => $class, | ||||
| 26 | method_name => $name | ||||
| 27 | ); | ||||
| 28 | |||||
| 29 | my $_super_package = $super->package_name; | ||||
| 30 | # BUT!,... if this is an overridden method .... | ||||
| 31 | if ($super->isa('Moose::Meta::Method::Overridden')) { | ||||
| 32 | # we need to be sure that we actually | ||||
| 33 | # find the next method, which is not | ||||
| 34 | # an 'override' method, the reason is | ||||
| 35 | # that an 'override' method will not | ||||
| 36 | # be the one calling inner() | ||||
| 37 | my $real_super = $meta->_find_next_method_by_name_which_is_not_overridden($name); | ||||
| 38 | $_super_package = $real_super->package_name; | ||||
| 39 | } | ||||
| 40 | |||||
| 41 | my $super_body = $super->body; | ||||
| 42 | |||||
| 43 | my $method = $args{method}; | ||||
| 44 | |||||
| 45 | my $body = sub { | ||||
| 46 | local $Moose::INNER_ARGS{$_super_package} = [ @_ ]; | ||||
| 47 | local $Moose::INNER_BODY{$_super_package} = $method; | ||||
| 48 | $super_body->(@_); | ||||
| 49 | }; | ||||
| 50 | |||||
| 51 | # FIXME store additional attrs | ||||
| 52 | $class->wrap( | ||||
| 53 | $body, | ||||
| 54 | package_name => $meta->name, | ||||
| 55 | name => $name | ||||
| 56 | ); | ||||
| 57 | } | ||||
| 58 | |||||
| 59 | 1 | 2µs | 1; | ||
| 60 | |||||
| 61 | # ABSTRACT: A Moose Method metaclass for augmented methods | ||||
| 62 | |||||
| 63 | __END__ |