blib/lib/Mouse/Meta/Method/Destructor.pm

filter: Statementstmt 29.1% 7 / 24 Branchbran 12.5% 1 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod n/a totaltotal 28.5% 10 / 35 CC 6 SCAR 29.6
CC
6
Cov
25%
_generate_destructor
30.0
BEGIN
2.0
BEGIN
1.0
CRAP 19.4
« blib/lib/Mouse/Util/MetaRole.pm ↑ Summary blib/lib/Mouse/Meta/Module.pm »
1 package Mouse::Meta::Method::Destructor;
2 1 ▶use Mouse::Util qw(:meta); # enables strict and warnings
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶use constant _MOUSE_DEBUG => $ENV{MOUSE_DEBUG} ? 1 : 0;
Subroutine BEGIN: called CC=2 SCAR=7.1
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'MOUSE_DEBUG'} ? : 0 1 1
5  
6 0 ▶sub _generate_destructor{
Subroutine _generate_destructor: not called CC=5 SCAR=34.0
7 0 my (undef, $metaclass) = @_;
8  
9 0 my $demolishall = '';
10 0 for my $class ($metaclass->linearized_isa) {
11 0 ▶ if (Mouse::Util::get_code_ref($class, 'DEMOLISH')) {
Branch: 1 branch
BranchTrueFalseTotal
if (Mouse::Util::get_code_ref($class, "DEMOLISH")) 0 0 0
12 0 $demolishall .= ' ' . $class
13 . '::DEMOLISH($self, Mouse::Util::in_global_destruction());'
14 . "\n",
15 }
16 }
17  
18 0 ▶ if($demolishall) {
Branch: 1 branch
BranchTrueFalseTotal
if ($demolishall) 0 0 0
19 0 $demolishall = sprintf <<'EOT', $demolishall;
20 my $e = do{
21 local $?;
22 local $@;
23 eval{
24 %s;
25 };
26 $@;
27 };
28 no warnings 'misc';
29 die $e if $e; # rethrow
30 EOT
31 }
32  
33 0 my $name = $metaclass->name;
34 0 my $source = sprintf(<<'EOT', __FILE__, $name, $demolishall);
35 #line 1 "%s"
36 package %s;
37 sub {
38 my($self) = @_;
39 return $self->Mouse::Object::DESTROY()
40 if ref($self) ne __PACKAGE__;
41 # DEMOLISHALL
42 %s;
43 return;
44 }
45 EOT
46  
47 0 warn $source if _MOUSE_DEBUG;
48  
49 0 my $code;
50 0 my $e = do{
51 0 local $@;
52 0 $code = eval $source;
53 0 $@;
54 };
55 0 ▶ die $e if $e;
Branch: 1 branch
BranchTrueFalseTotal
if $e 0 0 0
56 0 return $code;
57 }
58  
59 1 1;
60 __END__
« blib/lib/Mouse/Util/MetaRole.pm ↑ Summary blib/lib/Mouse/Meta/Module.pm »