| 1 | package MooseX::Singleton::Role::Object; | ||||||||||||||||||||||||||||
| 2 | 7 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use Carp qw( confess ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 7 | our $VERSION = '0.30'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 12 | ▶ | sub instance { shift->new } | ||||||||||||||||||||||||||
|
Subroutine
instance: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | sub initialize { | ||||||||||||||||||||||||||
|
Subroutine
initialize: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 10 | 3 | my ( $class, @args ) = @_; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 3 | my $existing = $class->meta->existing_singleton; | |||||||||||||||||||||||||||
| 13 | 3 | ▶ | confess "Singleton is already initialized" if $existing; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 2 | return $class->new(@args); | |||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 15 | ▶ | override new => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 19 | 15 | my ( $class, @args ) = @_; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 15 | my $existing = $class->meta->existing_singleton; | |||||||||||||||||||||||||||
| 22 | 15 | ▶ | confess "Singleton is already initialized" if $existing and @args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$existing and @args
MC/DC100%2/2
$existing and @args
$existing
@args
Truth table100%3/3
A and B
A= $existingB= @args
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | # Otherwise BUILD will be called repeatedly on the existing instance. | ||||||||||||||||||||||||||||
| 25 | # -- rjbs, 2008-02-03 | ||||||||||||||||||||||||||||
| 26 | 14 | ▶ | return $existing if $existing and !@args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$existing and not @args
MC/DC50%1/2
$existing and not @args
$existing
not @args
Truth table66%2/3
A and not(B)
A= $existingB= not @args
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 9 | return super(); | |||||||||||||||||||||||||||
| 29 | 7 | }; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 1 | ▶ | sub _clear_instance { | ||||||||||||||||||||||||||
|
Subroutine
_clear_instance: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | 1 | my ($class) = @_; | |||||||||||||||||||||||||||
| 33 | 1 | $class->meta->clear_singleton; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 7 | ▶ | no Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 7 | 1; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | # ABSTRACT: Object class role for MooseX::Singleton | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | __END__ | ||||||||||||||||||||||||||||