blib/lib/Class/WhiteHole.pm

filter: Statementstmt 100% 17 / 17 Branchbran 100% 2 / 2 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 88.8% 24 / 27 CC 3 SCAR 7.9
CC
3
Cov
95%
AUTOLOAD
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
↑ Summary
1 # $Id: WhiteHole.pm,v 1.4 2001/02/07 11:42:37 schwern Exp $
2  
3 package Class::WhiteHole;
4  
5 1 require 5;
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use vars qw(@ISA $VERSION $ErrorMsg);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 $VERSION = '0.04';
10 1 @ISA = ();
11  
12 # From 5.6.0's perldiag.
13 1 $ErrorMsg = qq{Can\'t locate object method "%s" via package "%s" }.
14 qq{at %s line %d.\n};
15  
16  
17 =pod
18  
19 =head1 NAME
20  
21 Class::WhiteHole - base class to treat unhandled method calls as errors
22  
23  
24 =head1 SYNOPSIS
25  
26 package Bar;
27  
28 # DBI inherits from DynaLoader which inherits from AutoLoader
29 # Bar wants to avoid this accidental inheritance of AutoLoader.
30 use base qw(Class::WhiteHole DBI);
31  
32  
33 =head1 DESCRIPTION
34  
35 Its possible to accidentally inherit an AUTOLOAD method. Often this
36 will happen if a class somewhere in the chain uses AutoLoader or
37 defines one of their own. This can lead to confusing error messages
38 when method lookups fail.
39  
40 Sometimes you want to avoid this accidental inheritance. In that
41 case, inherit from Class::WhiteHole. All unhandled methods will
42 produce normal Perl error messages.
43  
44  
45 =head1 BUGS & CAVEATS
46  
47 Be sure to have Class::WhiteHole before the class from which you're
48 inheriting AUTOLOAD in the ISA. Usually you'll want Class::WhiteHole
49 to come first.
50  
51 If your class inherits autoloaded routines this class may cause them
52 to stop working. Choose wisely before using.
53  
54 White holes are only a hypothesis and may not really exist.
55  
56  
57 =head1 COPYRIGHT
58  
59 Copyright 2000 Michael G Schwern <schwern@pobox.com> all rights
60 reserved. This program is free software; you can redistribute it
61 and/or modify it under the same terms as Perl itself.
62  
63  
64 =head1 AUTHOR
65  
66 Michael G Schwern <schwern@pobox.com>
67  
68 =head1 SEE ALSO
69  
70 L<Class::BlackHole>
71  
72 =cut
73  
74 2 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=3 SCAR=11.0
75 2 my($proto) = shift;
76 2 ▶ my($class) = ref $proto || $proto;
Condition66%2/3
ref $proto || $proto
l!l&&r!l&&!r
110
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table66%2/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
77  
78 2 my($meth) = $Class::WhiteHole::AUTOLOAD =~ m/::([^:]+)$/;
79  
80 2 ▶ return if $meth eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $meth eq "DESTROY" 1 1 2
81  
82 1 my($callpack, $callfile, $callline) = caller;
83  
84 1 die sprintf $ErrorMsg, $meth, $class, $callfile, $callline;
85 }
86  
87  
88 1 1;
89  
↑ Summary