line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Role::Singleton; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
## no critic (RequireUseStrict) - Role::Tiny does strict |
4
|
4
|
|
|
4
|
|
77149
|
use Role::Tiny; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
28
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
$Role::Singleton::VERSION = '0.2'; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
1
|
29
|
sub instance { goto &singleton; } |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub singleton { |
11
|
6
|
|
|
6
|
1
|
7292
|
my ( $self, @args ) = @_; |
12
|
6
|
|
33
|
|
|
46
|
my $class = ref($self) || $self; |
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
923
|
no strict 'refs'; ## no critic |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
247
|
|
15
|
6
|
|
66
|
|
|
10
|
return ${ $class . '::_singleton' } ||= $self->new(@args); |
|
6
|
|
|
|
|
166
|
|
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# need this or YAGNI ? |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
# sub clear_singleton { |
21
|
|
|
|
|
|
|
# my ($self) = @_; |
22
|
|
|
|
|
|
|
# my $class = ref($self) || $self; |
23
|
|
|
|
|
|
|
# |
24
|
|
|
|
|
|
|
# no strict 'refs'; |
25
|
|
|
|
|
|
|
# undef ${ $class . '::_singleton' }; |
26
|
|
|
|
|
|
|
# |
27
|
|
|
|
|
|
|
# return 1; |
28
|
|
|
|
|
|
|
# } |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
__END__ |