blib/lib/Object/Sub.pm

filter: Statementstmt 100% 21 / 21 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 1 totaltotal 87.8% 29 / 33 SCAR 11.0
CC
3
Cov
92%
AUTOLOAD
2.0
new
2.0
BEGIN
1.0
CRAP 3.0
↑ Summary
1 package Object::Sub;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '0.102';
6  
7 1 our $AUTOLOAD;
8  
9 use overload fallback => 1,
10 '&{}' => sub {
11 3 ▶ my $self_ref = \$_[0];
Subroutine __ANON__: called CC=1 SCAR=0.0
12  
13 return sub {
14 3 ▶ return $$self_ref->{cb}->($$self_ref, undef, @_);
Subroutine __ANON__: called CC=1 SCAR=0.0
15 3 };
16 1 ▶ };
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 sub AUTOLOAD {
19 3 ▶ die "$_[0] is not an object" if !ref $_[0];
Subroutine AUTOLOAD: called CC=2 SCAR=7.0
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_[0] 0 3 3
20  
21 3 my $name = $AUTOLOAD;
22 3 $name =~ s/.*://;
23  
24 3 return $_[0]->{cb}->($_[0], $name, @_[1 .. $#_]);
25 }
26  
27 sub new {
28 5 ▶ my ($class, $cb) = @_;
Subroutine new: called CC=2 SCAR=7.0
Pod undocumented
29  
30 5 ▶ die "need a callback" if ref $cb ne 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $cb ne "CODE" 0 5 5
31  
32 5 my $self = { cb => $cb, };
33 5 bless $self, $class;
34  
35 5 return $self;
36 }
37  
38 ## Prevent DESTROY method from being handled by AUTOLOAD
39  
40 ▶sub DESTROY {
Subroutine DESTROY: not called CC=1 SCAR=0.0
41 }
42  
43  
44 1 1;
45  
46  
47  
48 __END__
↑ Summary