line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Singleton Pattern for Bubblegum via Moo |
2
|
|
|
|
|
|
|
package Bubblegum::Singleton; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
358
|
use 5.10.0; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
91
|
|
5
|
2
|
|
|
2
|
|
2048
|
use namespace::autoclean; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Moo 'with'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'Bubblegum::Role::Configuration'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.44'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub import { |
14
|
|
|
|
|
|
|
my $target = caller; |
15
|
|
|
|
|
|
|
my $class = shift; |
16
|
|
|
|
|
|
|
my @export = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$class->prerequisites($target); |
19
|
|
|
|
|
|
|
Moo->import::into($target, @export); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $inst; |
22
|
|
|
|
|
|
|
my $orig = $class->can('new'); |
23
|
|
|
|
|
|
|
no strict 'refs'; |
24
|
|
|
|
|
|
|
*{"${target}::new"} = sub { |
25
|
|
|
|
|
|
|
$inst //= $orig->(@_) |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
if (!$class->can('renew')) { |
29
|
|
|
|
|
|
|
*{"${target}::renew"} = sub { |
30
|
|
|
|
|
|
|
$inst = $orig->(@_) |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__END__ |