| 1 | package EO::Singleton; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 4 | ▶ | use EO; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 4 | our @ISA = qw( EO ); | |||||||||||||||||||
| 8 | 4 | our $VERSION = 0.96; | |||||||||||||||||||
| 9 | 4 | my $_singletons = {}; | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 15 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||
| 12 | 15 | my $class = shift; | |||||||||||||||||||
| 13 | 15 | ▶ | $_singletons->{$class} ||= $class->SUPER::new(@_); | ||||||||||||||||||
|
Condition66%2/3
$_singletons->{$class} ||= $class->SUPER::new(@_)
MC/DC0%0/2
$_singletons->{$class} ||= $class->SUPER::new(@_)
$_singletons->{$class}
$class->SUPER::new(@_)
Truth table66%2/3
A ||= B
A= $_singletons->{$class}B= $class->SUPER::new(@_)
| |||||||||||||||||||||
| 14 | } | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 0 | ▶ | sub _reset_singleton { | ||||||||||||||||||
|
Subroutine
_reset_singleton: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 17 | 0 | my $self = shift; | |||||||||||||||||||
| 18 | 0 | $_singletons->{ ref($self) } = $self; | |||||||||||||||||||
| 19 | } | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 0 | ▶ | sub get { | ||||||||||||||||||
|
Subroutine
get: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 22 | 0 | ▶ | my $self = ref($_[0]) ? shift : shift->new; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 23 | 0 | $self->SUPER::get( @_ ); | |||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 0 | ▶ | sub set { | ||||||||||||||||||
|
Subroutine
set: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 27 | 0 | ▶ | my $self = ref($_[0]) ? shift : shift->new; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 28 | 0 | $self->SUPER::set( @_ ); | |||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 1 | ▶ | sub clone { | ||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 32 | 1 | my $self = shift; | |||||||||||||||||||
| 33 | 1 | return $self; | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 4 | 1; | |||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | __END__ | ||||||||||||||||||||