Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Method/Augmented.pm |
Statements | Executed 10 statements in 276µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 8µs | 8µs | BEGIN@2 | Moose::Meta::Method::Augmented::
1 | 1 | 1 | 6µs | 10µs | BEGIN@10 | Moose::Meta::Method::Augmented::
1 | 1 | 1 | 6µs | 18µs | BEGIN@9 | Moose::Meta::Method::Augmented::
1 | 1 | 1 | 6µs | 61µs | BEGIN@12 | Moose::Meta::Method::Augmented::
0 | 0 | 0 | 0s | 0s | __ANON__[:49] | Moose::Meta::Method::Augmented::
0 | 0 | 0 | 0s | 0s | new | Moose::Meta::Method::Augmented::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moose::Meta::Method::Augmented; | ||||
2 | # spent 8µs within Moose::Meta::Method::Augmented::BEGIN@2 which was called:
# once (8µs+0s) by Moose::Meta::Class::BEGIN@22 at line 4 | ||||
3 | 1 | 4µs | $Moose::Meta::Method::Augmented::AUTHORITY = 'cpan:STEVAN'; | ||
4 | 1 | 29µs | 1 | 8µs | } # spent 8µs making 1 call to Moose::Meta::Method::Augmented::BEGIN@2 |
5 | { | ||||
6 | 2 | 900ns | $Moose::Meta::Method::Augmented::VERSION = '2.1005'; | ||
7 | } | ||||
8 | |||||
9 | 2 | 22µs | 2 | 29µs | # spent 18µs (6+11) within Moose::Meta::Method::Augmented::BEGIN@9 which was called:
# once (6µs+11µs) by Moose::Meta::Class::BEGIN@22 at line 9 # spent 18µs making 1 call to Moose::Meta::Method::Augmented::BEGIN@9
# spent 11µs making 1 call to strict::import |
10 | 2 | 22µs | 2 | 13µs | # spent 10µs (6+3) within Moose::Meta::Method::Augmented::BEGIN@10 which was called:
# once (6µs+3µs) by Moose::Meta::Class::BEGIN@22 at line 10 # spent 10µs making 1 call to Moose::Meta::Method::Augmented::BEGIN@10
# spent 3µs making 1 call to warnings::import |
11 | |||||
12 | 2 | 196µs | 2 | 116µs | # spent 61µs (6+55) within Moose::Meta::Method::Augmented::BEGIN@12 which was called:
# once (6µs+55µs) by Moose::Meta::Class::BEGIN@22 at line 12 # spent 61µs making 1 call to Moose::Meta::Method::Augmented::BEGIN@12
# spent 55µs making 1 call to base::import |
13 | |||||
14 | sub new { | ||||
15 | my ( $class, %args ) = @_; | ||||
16 | |||||
17 | # the package can be overridden by roles | ||||
18 | # it is really more like body's compilation stash | ||||
19 | # this is where we need to override the definition of super() so that the | ||||
20 | # body of the code can call the right overridden version | ||||
21 | my $name = $args{name}; | ||||
22 | my $meta = $args{class}; | ||||
23 | |||||
24 | my $super = $meta->find_next_method_by_name($name); | ||||
25 | |||||
26 | (defined $super) | ||||
27 | || $meta->throw_error("You cannot augment '$name' because it has no super method", data => $name); | ||||
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 | 3µs | 1; | ||
60 | |||||
61 | # ABSTRACT: A Moose Method metaclass for augmented methods | ||||
62 | |||||
63 | __END__ |