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

filter: Statementstmt 100% 39 / 39 Branchbran 100% 2 / 2 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 94.5% 52 / 55 CC 3 SCAR 3.2
CC
3
Cov
98%
new
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« blib/lib/Moose/Meta/Method/Accessor/Native/Array/set.pm ↑ Summary blib/lib/Moose/Meta/Method/Accessor/Native/Hash/set.pm »
1 package Moose::Meta::Method::Overridden;
2 346 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 1012 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
12 1012 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 1012 ▶ my $super_package = $args{package} || $args{class}->name;
Condition66%2/3
$args{'package'} || $args{'class'}->name
l!l&&r!l&&!r
994180
MC/DC0%0/2
$args{'package'} || $args{'class'}->name
$args{'package'} $args{'class'}->name
Truth table66%2/3
A || B
A= $args{'package'}B= $args{'class'}->name
ABresult
1X1
011
000
19  
20 1012 my $name = $args{name};
21  
22 1012 my $super = $args{class}->find_next_method_by_name($name);
23  
24 1012 ▶ (defined $super)
Branch: 1 branch
BranchTrueFalseTotal
defined $super or throw_exception("CannotOverrideNoSuperMethod", "class", $class, "params", \%args, "method_name", $name) 1010 2 1012
25 || throw_exception( CannotOverrideNoSuperMethod => class => $class,
26 params => \%args,
27 method_name => $name
28 );
29  
30 1010 my $super_body = $super->body;
31  
32 1010 my $method = $args{method};
33  
34 458 ▶ my $body = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine _inline_store_value: called CC=1 SCAR=0.0
Subroutine _eval_environment: called CC=1 SCAR=0.0
35 458 local $Moose::SUPER_PACKAGE = $super_package;
36 458 local @Moose::SUPER_ARGS = @_;
37 458 local $Moose::SUPER_BODY = $super_body;
38 458 return $method->(@_);
39 1010 };
40  
41 # FIXME do we need this make sure this works for next::method?
42 # subname "${super_package}::${name}", $method;
43  
44 # FIXME store additional attrs
45 $class->wrap(
46 $body,
47 package_name => $args{class}->name,
48 1010 name => $name
49 );
50 }
51  
52 346 1;
53  
54 # ABSTRACT: A Moose Method metaclass for overridden methods
55  
56 __END__
« blib/lib/Moose/Meta/Method/Accessor/Native/Array/set.pm ↑ Summary blib/lib/Moose/Meta/Method/Accessor/Native/Hash/set.pm »