| 1 | package Bread::Board::LifeCycle::Session::WithParameters; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | our $AUTHORITY = 'cpan:GSG'; | |||||||||
| 4 | 2 | our $VERSION = '0.90'; | |||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use Module::Runtime (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 2 | our $FLUSHER_ROLE = 'Bread::Board::Container::Role::WithSessions'; | |||||||||
| 11 | |||||||||||
| 12 | 2 | with 'Bread::Board::LifeCycle::Singleton::WithParameters'; | |||||||||
| 13 | |||||||||||
| 14 | ### XXX: Lifecycle consumption happens after service construction, | ||||||||||
| 15 | ### so we have pick a method that would get called after | ||||||||||
| 16 | ### construction. The 'get' method is pretty hot, so this should | ||||||||||
| 17 | ### be done as fast as possible. | ||||||||||
| 18 | |||||||||||
| 19 | 4 | ▶ | before get => sub { | ||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||
| 20 | 4 | my $self = shift; | |||||||||
| 21 | |||||||||||
| 22 | # Assume we've already done this if any instance exists | ||||||||||
| 23 | 4 | ▶ | return if values %{$self->instances}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | |||||||||||
| 25 | 2 | Module::Runtime::require_module($FLUSHER_ROLE); | |||||||||
| 26 | |||||||||||
| 27 | 2 | my @containers = ($self->get_root_container); | |||||||||
| 28 | |||||||||||
| 29 | # Traverse the sub containers and apply the WithSessions role | ||||||||||
| 30 | 2 | ▶ | while (my $container = shift @containers) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 2 | push @containers, values %{$container->sub_containers}; | |||||||||
| 32 | |||||||||||
| 33 | 2 | ▶ | Class::MOP::class_of($FLUSHER_ROLE)->apply($container) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | unless $container->meta->does_role($FLUSHER_ROLE); | ||||||||||
| 35 | } | ||||||||||
| 36 | 2 | }; | |||||||||
| 37 | |||||||||||
| 38 | 2 | 1; | |||||||||
| 39 | |||||||||||
| 40 | __END__ | ||||||||||