line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bot::Cobalt::Core::Role::Singleton; |
2
|
|
|
|
|
|
|
$Bot::Cobalt::Core::Role::Singleton::VERSION = '0.021003'; |
3
|
5
|
|
|
5
|
|
5081
|
use Carp 'confess'; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
261
|
|
4
|
5
|
|
|
5
|
|
20
|
use strictures 2; |
|
5
|
|
|
|
|
29
|
|
|
5
|
|
|
|
|
190
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
854
|
use Moo::Role; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
31
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
1235
|
no strict 'refs'; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
829
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub instance { |
11
|
3
|
|
|
3
|
1
|
2658
|
my $class = $_[0]; |
12
|
|
|
|
|
|
|
|
13
|
3
|
|
|
|
|
4
|
my $this_obj = \${$class.'::_singleton'}; |
|
3
|
|
|
|
|
18
|
|
14
|
|
|
|
|
|
|
|
15
|
3
|
100
|
|
|
|
21
|
defined $$this_obj ? $$this_obj |
16
|
|
|
|
|
|
|
: ( $$this_obj = $class->new(@_[1 .. $#_]) ) |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub has_instance { |
20
|
8
|
|
66
|
8
|
1
|
510
|
my $class = ref $_[0] || $_[0]; |
21
|
8
|
|
|
|
|
10
|
!! ${$class.'::_singleton'}; |
|
8
|
|
|
|
|
66
|
|
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub clear_instance { |
25
|
1
|
|
33
|
1
|
1
|
5
|
my $class = ref $_[0] || $_[0]; |
26
|
1
|
|
|
|
|
2
|
${$class.'::_singleton'} = undef; |
|
1
|
|
|
|
|
7
|
|
27
|
1
|
|
|
|
|
4
|
1 |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub is_instanced { |
31
|
0
|
|
|
0
|
0
|
|
confess "is_instanced is deprecated; use has_instance" |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
__END__ |