line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Role::Multiton; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
## no critic (RequireUseStrict) - Role::Tiny does strict |
4
|
4
|
|
|
4
|
|
97653
|
use Role::Tiny; |
|
4
|
|
|
|
|
4890
|
|
|
4
|
|
|
|
|
32
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
$Role::Multiton::VERSION = '0.2'; |
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
2394
|
use Role::_Multiton (); |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
491
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
1
|
41
|
sub instance { goto &multiton; } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub multiton { |
13
|
8
|
|
|
8
|
1
|
2825
|
my ( $self, @args ) = @_; |
14
|
|
|
|
|
|
|
|
15
|
8
|
|
|
|
|
31
|
my $arg_key = Role::_Multiton::_get_arg_key( \@args ); |
16
|
|
|
|
|
|
|
|
17
|
8
|
|
|
|
|
24
|
my $multiton_hr = Role::_Multiton::_get_multiton_lookup_hr($self); |
18
|
|
|
|
|
|
|
|
19
|
8
|
|
66
|
|
|
170
|
return $multiton_hr->{$arg_key} ||= $self->new(@args); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Need these or YAGNI? |
23
|
|
|
|
|
|
|
# |
24
|
|
|
|
|
|
|
# sub get_multiton_lookup_hr { goto &Role::_Multiton::_get_multiton_lookup_hr; } |
25
|
|
|
|
|
|
|
# |
26
|
|
|
|
|
|
|
# sub get_my_multiton_key { |
27
|
|
|
|
|
|
|
# my ($self) = @_; |
28
|
|
|
|
|
|
|
# |
29
|
|
|
|
|
|
|
# my $multiton_hr = $self->get_multiton_lookup_hr(); |
30
|
|
|
|
|
|
|
# for my $arg_key ( keys %{ $multiton_hr } ) { |
31
|
|
|
|
|
|
|
# if ( "$multiton_hr->{$arg_key}" eq "$self" ) { |
32
|
|
|
|
|
|
|
# return $arg_key; |
33
|
|
|
|
|
|
|
# } |
34
|
|
|
|
|
|
|
# } |
35
|
|
|
|
|
|
|
# |
36
|
|
|
|
|
|
|
# return; |
37
|
|
|
|
|
|
|
# } |
38
|
|
|
|
|
|
|
# |
39
|
|
|
|
|
|
|
# sub clear_my_multiton_key { |
40
|
|
|
|
|
|
|
# my ($self) = @_; |
41
|
|
|
|
|
|
|
# |
42
|
|
|
|
|
|
|
# my $arg_key = $self->get_multiton_arg_key() || return; |
43
|
|
|
|
|
|
|
# my $multiton_hr = $self->get_multiton_lookup_hr(); |
44
|
|
|
|
|
|
|
# |
45
|
|
|
|
|
|
|
# return delete $multiton_hr->{$arg_key}; |
46
|
|
|
|
|
|
|
# } |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |