blib/lib/Class/Proxy.pm

filter: Statementstmt 55.0% 22 / 40 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 60.0% 6 / 10 Podpod 100% 1 / 1 totaltotal 45.3% 29 / 64 CC 7 SCAR 24.3
CC
7
Cov
42%
AUTOLOAD
30.0
_postinit
6.0
victim
6.0
CRAP 11.4
↑ Summary
1 1 ▶require 5.005_62; use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
2
3 1 our $VERSION = '0.01.04';
4
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6
7 1 ▶use Class::Maker;
Subroutine BEGIN: called CC=1 SCAR=0.0
8
9 1 ▶use Class::Listener;
Subroutine BEGIN: called CC=1 SCAR=0.0
10
11 package Class::Proxy;
12
13 1 Class::Maker::class
14 {
15 isa => [qw( Class::Listener )],
16
17 private =>
18 {
19 ref => { victim => 'UNIVERSAL' },
20 },
21 };
22
23 1 ▶use vars qw($AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
24
25 sub _preinit
26 0 ▶{
Subroutine _preinit: not called CC=1 SCAR=6.9
27 0 my $this = shift;
28
29 0 $this->_victim( undef );
30 }
31
32 sub _postinit
33 0 ▶{
Subroutine _postinit: not called CC=2 SCAR=17.9
34 0 my $this = shift;
35
36 0 ▶ $this->victim( $this->_victim ) if $this->_victim;
Branch: 1 branch
BranchTrueFalseTotal
if $this->_victim 0 0 0
37 }
38
39 0 ▶sub victim : method
Subroutine victim: not called CC=2 SCAR=17.9
Pod documented
40 {
41 0 my $this = shift;
42
43 0 my $destination = shift;
44
45 # Binding to class or object...
46
47 0 ▶ $this->_victim( ref($destination) ? $destination : $destination->new( @_ ) );
Branch: 1 branch
BranchTrueFalseTotal
ref $destination ? : 0 0 0
48
49 0 $this->signal( 'victim', $this->_victim );
50
51 0 return $this->_victim;
52 }
53
54 # Future: Class::Proxy should more obscure himself
55 #
56 # "goto &func" would be the best solution.
57 #
58 # #my $fullfunc = \&{ "${destpack}::$func" };
59 # #goto &$fullfunc if $victim->can( $func ) or die "unhandled method $victim->$func via Obsessor";
60
61 0 ▶sub AUTOLOAD : method
Subroutine AUTOLOAD: not called CC=5 SCAR=34.0
62 {
63 0 ▶ my $this = shift || return undef;
Condition0%0/2
shift() || (return undef)
l!l
00
MC/DC0%0/1
shift() || (return undef)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
64
65 0 my @args = @_;
66
67 0 ( my $func = $AUTOLOAD ) =~ s/.*:://;
68
69 0 ▶ return if $func eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $func eq "DESTROY" 0 0 0
70
71 #no strict 'refs';
72
73 0 @_ = @args;
74
75 0 $this->Class::Listener::signal( 'method', \$func, \$this->_victim, \@args );
76
77 0 ▶ die "unimplemented '$func' called on ".ref( $this->_victim ) unless $this->_victim->can( $func );
Branch: 1 branch
BranchTrueFalseTotal
unless $this->_victim->can($func) 0 0 0
78
79 0 ▶return wantarray ? @{ [ $this->_victim->$func( @_ ) ] } : $this->_victim->$func( @_ );
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
80 }
81
82 1 1;
83
84 __END__
↑ Summary