blib/lib/Moose/Meta/Method/Augmented.pm

filter: Statementstmt 100% 33 / 33 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 100% 45 / 45 CC 3 SCAR 5.1
CC
3
Cov
100%
new
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.7
« blib/lib/Moose/Exception/WrapTakesACodeRefToBless.pm ↑ Summary blib/lib/Moose/Exception/OverloadConflictInSummation.pm »
1 package Moose::Meta::Method::Augmented;
2 386 our $VERSION = '2.4001';
3  
4 388 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 388 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 388 ▶use parent 'Moose::Meta::Method';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 388 ▶use Moose::Util 'throw_exception';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 14 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
12 14 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 14 my $name = $args{name};
19 14 my $meta = $args{class};
20  
21 14 my $super = $meta->find_next_method_by_name($name);
22  
23 14 ▶ (defined $super)
Branch: 1 branch
BranchTrueFalseTotal
defined $super or throw_exception("CannotAugmentNoSuperMethod", "params", \%args, "class", $class, "method_name", $name) 13 1 14
24 || throw_exception( CannotAugmentNoSuperMethod => params => \%args,
25 class => $class,
26 method_name => $name
27 );
28  
29 13 my $_super_package = $super->package_name;
30 # BUT!,... if this is an overridden method ....
31 13 ▶ if ($super->isa('Moose::Meta::Method::Overridden')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($super->isa("Moose::Meta::Method::Overridden")) 1 12 13
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 1 my $real_super = $meta->_find_next_method_by_name_which_is_not_overridden($name);
38 1 $_super_package = $real_super->package_name;
39 }
40  
41 13 my $super_body = $super->body;
42  
43 13 my $method = $args{method};
44  
45 6 ▶ my $body = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine foo: called CC=1 SCAR=0.0
46 6 local $Moose::INNER_ARGS{$_super_package} = [ @_ ];
47 6 local $Moose::INNER_BODY{$_super_package} = $method;
48 6 $super_body->(@_);
49 13 };
50  
51 # FIXME store additional attrs
52 13 $class->wrap(
53 $body,
54 package_name => $meta->name,
55 name => $name
56 );
57 }
58  
59 386 1;
60  
61 # ABSTRACT: A Moose Method metaclass for augmented methods
62  
63 __END__
« blib/lib/Moose/Exception/WrapTakesACodeRefToBless.pm ↑ Summary blib/lib/Moose/Exception/OverloadConflictInSummation.pm »