line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Scope::Session::Singleton; |
2
|
1
|
|
|
1
|
|
15387
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
46
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
7
|
1
|
|
|
1
|
|
5
|
use Scope::Session; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
22
|
use constant FORMAT_OF_POOL_KEY => q|scope-session-singleton:%s|; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
291
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub instance { |
12
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
13
|
0
|
|
|
|
|
|
my $instance = $class->_get_instance; |
14
|
0
|
0
|
|
|
|
|
unless ( defined $instance ) { |
15
|
0
|
|
|
|
|
|
$instance = $class->_new_instance(@_); |
16
|
0
|
|
|
|
|
|
$class->_set_instance($instance); |
17
|
|
|
|
|
|
|
} |
18
|
0
|
|
|
|
|
|
return $instance; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _new_instance { |
22
|
0
|
|
|
0
|
|
|
bless {}, shift; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _get_instance { |
26
|
0
|
|
|
0
|
|
|
my $class = shift; |
27
|
0
|
|
|
|
|
|
Scope::Session->notes->get( sprintf( $class->FORMAT_OF_POOL_KEY, $class ) ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _set_instance { |
31
|
0
|
|
|
0
|
|
|
my ( $class, $instance ) = @_; |
32
|
0
|
|
|
|
|
|
Scope::Session->notes->set( |
33
|
|
|
|
|
|
|
sprintf( $class->FORMAT_OF_POOL_KEY, $class ) => $instance ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
__END__ |