| 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
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 51 | 0 | ▶ | $call->($data->{'self'},@_) if *$call{CODE}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 52 | } else { | ||||||||||||||||||||
| 53 | 70 | ▶ | push(@{$data->{'result_set'}},$call->($data->{'self'},@_)) if *$call{CODE}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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__ | ||||||||||||||||||||