blib/lib/Method/Generate/DemolishAll.pm

filter: Statementstmt 100% 27 / 27 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 2 totaltotal 94.7% 36 / 38 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Method/Generate/BuildAll.pm ↑ Summary
1 package Method::Generate::DemolishAll;
2 24 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 24 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 24 ▶use Moo::Object ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 24 ▶BEGIN { our @ISA = qw(Moo::Object) }
Subroutine BEGIN: called CC=1 SCAR=0.0
7 24 ▶use Sub::Quote qw(quote_sub quotify);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 24 ▶use Moo::_Utils qw(_getglob _linear_isa _in_global_destruction_code);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 12 ▶sub generate_method {
Subroutine generate_method: called CC=1 SCAR=0.0
Pod undocumented
11 12 my ($self, $into) = @_;
12 12 quote_sub "${into}::DEMOLISHALL", join '',
13 $self->_handle_subdemolish($into),
14 qq{ my \$self = shift;\n},
15 $self->demolishall_body_for($into, '$self', '@_'),
16 qq{ return \$self\n};
17 12 quote_sub "${into}::DESTROY",
18 sprintf <<'END_CODE', $into, _in_global_destruction_code;
19 my $self = shift;
20 my $e;
21 {
22 local $?;
23 local $@;
24 package %s;
25 eval {
26 $self->DEMOLISHALL(%s);
27 1;
28 } or $e = $@;
29 }
30  
31 # fatal warnings+die in DESTROY = bad times (perl rt#123398)
32 no warnings FATAL => 'all';
33 use warnings 'all';
34 die $e if defined $e; # rethrow
35 END_CODE
36 }
37  
38 12 ▶sub demolishall_body_for {
Subroutine demolishall_body_for: called CC=1 SCAR=0.0
Pod undocumented
39 12 my ($self, $into, $me, $args) = @_;
40 my @demolishers =
41 29 grep *{_getglob($_)}{CODE},
42 map "${_}::DEMOLISH",
43 12 @{_linear_isa($into)};
44 12 join '',
45 qq{ package $into;\n},
46 map qq{ ${me}->${_}(${args});\n}, @demolishers;
47 }
48  
49 12 ▶sub _handle_subdemolish {
Subroutine _handle_subdemolish: called CC=1 SCAR=0.0
50 12 my ($self, $into) = @_;
51 12 ' if (ref($_[0]) ne '.quotify($into).') {'."\n".
52 " package $into;\n".
53 ' return shift->Moo::Object::DEMOLISHALL(@_)'.";\n".
54 ' }'."\n";
55 }
56  
57 24 1;
« blib/lib/Method/Generate/BuildAll.pm ↑ Summary