line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package MooX::Singleton; |
3
|
|
|
|
|
|
|
BEGIN { |
4
|
1
|
|
|
1
|
|
11306
|
$MooX::Singleton::AUTHORITY = 'cpan:AJGB'; |
5
|
|
|
|
|
|
|
} |
6
|
|
|
|
|
|
|
{ |
7
|
|
|
|
|
|
|
$MooX::Singleton::VERSION = '1.20'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
# ABSTRACT: turn your Moo class into singleton |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
9
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
12
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
13
|
1
|
|
|
1
|
|
4
|
use Role::Tiny; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub instance { |
17
|
30
|
|
|
30
|
1
|
10516
|
my $class = shift; |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
192
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
106
|
|
20
|
30
|
|
|
|
|
35
|
my $instance = \${"$class\::_instance"}; |
|
30
|
|
|
|
|
113
|
|
21
|
30
|
100
|
|
|
|
289
|
return defined $$instance ? $$instance |
22
|
|
|
|
|
|
|
: ( $$instance = $class->new(@_) ); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _has_instance { |
26
|
45
|
|
33
|
45
|
|
66287
|
my $class = ref $_[0] || $_[0]; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
91
|
|
29
|
45
|
|
|
|
|
62
|
return ${"$class\::_instance"}; |
|
45
|
|
|
|
|
333
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _clear_instance { |
33
|
15
|
|
33
|
15
|
|
20800
|
my $class = ref $_[0] || $_[0]; |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
69
|
|
36
|
15
|
|
|
|
|
24
|
undef ${"$class\::_instance"}; |
|
15
|
|
|
|
|
58
|
|
37
|
|
|
|
|
|
|
|
38
|
15
|
|
|
|
|
63
|
return $class; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |