blib/lib/Class/DispatchToAll.pm

filter: Statementstmt 97.0% 33 / 34 Branchbran 62.5% 5 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 85.1% 46 / 54 CC 7 SCAR 11.9
CC
7
Cov
87%
_dispatcher
5.2
dispatch_to_all
3.0
BEGIN
1.0
CRAP 3.3
↑ Summary
1 package Class::DispatchToAll;
2  
3 # ABSTRACT: DEPRECATED - dispatch a method call to all inherited methods
4 3 our $VERSION = '0.13'; # VERSION
5  
6 3 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 warn __PACKAGE__ .' is DEPRECATED, please do not use this module anymore';
11  
12 3 require Exporter;
13  
14 3 our @ISA = qw(Exporter);
15  
16 3 our @EXPORT_OK = (qw(dispatch_to_all));
17  
18 #-----------------------------------------------------------------
19 # dispatch_to_all
20 #-----------------------------------------------------------------
21 7 ▶sub dispatch_to_all {
Subroutine dispatch_to_all: called CC=3 SCAR=11.1
Pod documented
22 7 my $self=shift;
23 7 my $method=shift;
24 7 my $attributes=shift;
25 7 my @result_set;
26  
27 7 ▶ my $data={
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
700
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
28 self=>$self,
29 class=>ref($self)||$self,
30 method=>$method,
31 attribs=>$attributes,
32 result_set=>\@result_set,
33 };
34  
35 7 _dispatcher($data,@_);
36 7 ▶ return wantarray?@result_set:\@result_set;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 5 2 7
37 }
38  
39  
40 #-----------------------------------------------------------------
41 # dispatcher
42 #-----------------------------------------------------------------
43 70 ▶sub _dispatcher {
Subroutine _dispatcher: called CC=5 SCAR=16.6
44 70 my $data=shift;
45  
46 # dispatch to own package
47 3 ▶ no strict "refs";
Subroutine BEGIN: called CC=1 SCAR=0.0
48 70 my $call=$data->{'class'}."::".$data->{'method'};
49  
50 70 ▶ if ($data->{'attrib'}{'no_collect'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data->{'attrib'}{'no_collect'}) { } 0 70 70
51 0 ▶ $call->($data->{'self'},@_) if *$call{CODE};
Branch: 1 branch
BranchTrueFalseTotal
if *$call{"CODE"} 0 0 0
52 } else {
53 70 ▶ push(@{$data->{'result_set'}},$call->($data->{'self'},@_)) if *$call{CODE};
Branch: 1 branch
BranchTrueFalseTotal
if *$call{"CODE"} 34 36 70
54 }
55  
56 70 my @isa=eval "@".$data->{'class'}."::ISA";
57 70 foreach my $parent (@isa) {
58 63 $data->{'class'}=$parent;
59 63 _dispatcher($data,@_);
60 }
61 }
62  
63 3 1;
64  
65 __END__
↑ Summary