Autouse/Parent.pm

filter: Statementstmt 100% 17 / 17 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 96.0% 24 / 25 CC 3 SCAR 7.0
CC
3
Cov
95%
import
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« Autouse.pm ↑ Summary
1 package Class::Autouse::Parent;
2
3 # The package Class::Autouse::Parent can be inherited from to implement
4 # a parent class. That is, a class who's primary job is to load a series
5 # classes below it.
6
7 2 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Class::Autouse ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10
11 2 our $VERSION = '2.02';
12
13 # Anti-loop protection.
14 # Maintain flags for "is the class in the process of loading"
15 2 my %LOADING = ();
16
17 3 ▶sub import {
Subroutine import: called CC=3 SCAR=11.0
18 # If the parent value is ourselves, we were just
19 # 'use'd, not 'base'd.
20 3 ▶ my $parent = $_[0] ne __PACKAGE__ ? shift : return 1;
Branch: 1 branch
BranchTrueFalseTotal
$_[0] ne __PACKAGE__ ? : 1 2 3
21
22 # Don't load if already loading
23 1 ▶ return 1 if $LOADING{$parent};
Branch: 1 branch
BranchTrueFalseTotal
if $LOADING{$parent} 0 1 1
24
25 # Autoload in our children
26 1 $LOADING{$parent} = 1;
27 1 Class::Autouse->autouse_recursive($parent);
28 1 delete $LOADING{$parent};
29
30 1 return 1;
31 }
32
33 2 1;
« Autouse.pm ↑ Summary