line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bolts::Scope::Singleton; |
2
|
|
|
|
|
|
|
$Bolts::Scope::Singleton::VERSION = '0.143171'; |
3
|
|
|
|
|
|
|
# ABSTRACT: For artifacts that are reused for the lifetime of the bag |
4
|
|
|
|
|
|
|
|
5
|
11
|
|
|
11
|
|
47
|
use Moose; |
|
11
|
|
|
|
|
94
|
|
|
11
|
|
|
|
|
60
|
|
6
|
|
|
|
|
|
|
|
7
|
11
|
|
|
11
|
|
51412
|
use Hash::Util::FieldHash 'fieldhash'; |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
2067
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'Bolts::Scope'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
fieldhash my %singleton; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub get { |
15
|
61
|
|
|
61
|
1
|
92
|
my ($self, $bag, $name) = @_; |
16
|
|
|
|
|
|
|
|
17
|
61
|
100
|
|
|
|
217
|
return unless defined $singleton{$bag}; |
18
|
52
|
50
|
|
|
|
211
|
return unless defined $singleton{$bag}{$name}; |
19
|
52
|
|
|
|
|
118
|
return $singleton{$bag}{$name}; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub put { |
23
|
9
|
|
|
9
|
1
|
18
|
my ($self, $bag, $name, $artifact) = @_; |
24
|
|
|
|
|
|
|
|
25
|
9
|
50
|
|
|
|
88
|
$singleton{$bag} = {} unless defined $singleton{$bag}; |
26
|
9
|
|
|
|
|
35
|
$singleton{$bag}{$name} = $artifact; |
27
|
9
|
|
|
|
|
21
|
return; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
__END__ |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=pod |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=encoding UTF-8 |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 NAME |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Bolts::Scope::Singleton - For artifacts that are reused for the lifetime of the bag |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 VERSION |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
version 0.143171 |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 DESCRIPTION |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
This scope does not define a true singleton, but a singleton for the lifetime of the bag it is associated with, which might be the same thing. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 ROLES |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=over |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item * |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
L<Bolts::Scope> |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=back |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 METHODS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 get |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
If the named artifact has ever been stored for this bag, it will be returned by this method. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 put |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Puts the named artifact into the singleton cache for the bag. Once there, it will stay there for as long as the object exists. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 AUTHOR |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Andrew Sterling Hanenkamp <hanenkamp@cpan.org> |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Qubling Software LLC. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
79
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |