blib/lib/Bot/Cobalt/Core/Role/Singleton.pm

filter: Statementstmt 96.1% 25 / 26 Branchbran 100% 2 / 2 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 87.5% 7 / 8 Podpod 75.0% 3 / 4 totaltotal 78.0% 39 / 50 CC 4 SCAR 5.2
CC
4
Cov
85%
has_instance
2.1
clear_instance
2.1
instance
2.0
CRAP 1.7
« blib/lib/Bot/Cobalt/IRC/Event.pm ↑ Summary blib/lib/Bot/Cobalt/Conf/Role/Reader.pm »
1 package Bot::Cobalt::Core::Role::Singleton;
2 1 $Bot::Cobalt::Core::Role::Singleton::VERSION = '0.021003';
3 1 ▶use Carp 'confess';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶sub instance {
Subroutine instance: called CC=2 SCAR=6.9
Pod documented
11 2 my $class = $_[0];
12  
13 2 my $this_obj = \${$class.'::_singleton'};
14
15 2 ▶ defined $$this_obj ? $$this_obj
Branch: 1 branch
BranchTrueFalseTotal
defined $$this_obj ? : 1 1 2
16 : ( $$this_obj = $class->new(@_[1 .. $#_]) )
17 }
18  
19 2 ▶sub has_instance {
Subroutine has_instance: called CC=2 SCAR=7.6
Pod documented
20 2 ▶ my $class = ref $_[0] || $_[0];
Condition33%1/3
ref $_[0] || $_[0]
l!l&&r!l&&!r
200
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
Truth table33%1/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
21 2 !! ${$class.'::_singleton'};
22 }
23  
24 1 ▶sub clear_instance {
Subroutine clear_instance: called CC=2 SCAR=7.4
Pod documented
25 1 ▶ my $class = ref $_[0] || $_[0];
Condition33%1/3
ref $_[0] || $_[0]
l!l&&r!l&&!r
100
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
Truth table33%1/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
26 1 ${$class.'::_singleton'} = undef;
27 1 1
28 }
29  
30 0 ▶sub is_instanced {
Subroutine is_instanced: not called CC=1 SCAR=6.9
Pod undocumented
31 0 confess "is_instanced is deprecated; use has_instance"
32 }
33  
34 1 1;
35 __END__
« blib/lib/Bot/Cobalt/IRC/Event.pm ↑ Summary blib/lib/Bot/Cobalt/Conf/Role/Reader.pm »