| 1 | package Bolts::Scope::Singleton; | ||||||||||
| 2 | 11 | $Bolts::Scope::Singleton::VERSION = '0.143171'; | |||||||||
| 3 | # ABSTRACT: For artifacts that are reused for the lifetime of the bag | ||||||||||
| 4 | |||||||||||
| 5 | 11 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 11 | ▶ | use Hash::Util::FieldHash 'fieldhash'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 11 | with 'Bolts::Scope'; | |||||||||
| 10 | |||||||||||
| 11 | 11 | fieldhash my %singleton; | |||||||||
| 12 | |||||||||||
| 13 | |||||||||||
| 14 | 61 | ▶ | sub get { | ||||||||
|
Subroutine
get: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 15 | 61 | my ($self, $bag, $name) = @_; | |||||||||
| 16 | |||||||||||
| 17 | 61 | ▶ | return unless defined $singleton{$bag}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 52 | ▶ | return unless defined $singleton{$bag}{$name}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 52 | return $singleton{$bag}{$name}; | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | 9 | ▶ | sub put { | ||||||||
|
Subroutine
put: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 23 | 9 | my ($self, $bag, $name, $artifact) = @_; | |||||||||
| 24 | |||||||||||
| 25 | 9 | ▶ | $singleton{$bag} = {} unless defined $singleton{$bag}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 9 | $singleton{$bag}{$name} = $artifact; | |||||||||
| 27 | 9 | return; | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 11 | __PACKAGE__->meta->make_immutable; | |||||||||
| 31 | |||||||||||
| 32 | __END__ | ||||||||||