line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Singleton Declaration for Perl 5 |
2
|
|
|
|
|
|
|
package Data::Object::Singleton; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
891
|
use 5.010; |
|
1
|
|
|
|
|
4
|
|
5
|
1
|
|
|
1
|
|
751
|
use parent 'Moo'; |
|
1
|
|
|
|
|
273
|
|
|
1
|
|
|
|
|
4
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.42'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub import { |
10
|
1
|
|
|
1
|
|
11
|
my $class = shift; |
11
|
1
|
|
|
|
|
3
|
my $target = caller; |
12
|
1
|
|
|
|
|
3
|
my $state = undef; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
6
|
eval "package $target; use Moo; 1;"; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
64
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
|
|
11
|
my $new = $target->can('new'); |
17
|
1
|
|
|
|
|
7
|
my $renew = $target->can('renew'); |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
14835
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
126
|
|
20
|
|
|
|
|
|
|
|
21
|
1
|
100
|
|
3
|
|
5
|
*{"${target}::new"} = sub { $state = $new->(@_) if !$state; $state }; |
|
1
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
901
|
|
|
3
|
|
|
|
|
35
|
|
22
|
1
|
50
|
|
1
|
|
6
|
*{"${target}::renew"} = sub { $state = $new->(@_) } if !$renew; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
5
|
|
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
12
|
return; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
__END__ |