LifeCycle/Session.pm

filter: Statementstmt 100% 26 / 26 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 97.3% 36 / 37 CC 4 SCAR 9.2
CC
4
Cov
97%
__ANON__
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.5
« LifeCycle/Session/WithParameters.pm ↑ Summary
1 package Bread::Board::LifeCycle::Session;
2  
3 2 our $AUTHORITY = 'cpan:GSG';
4 # ABSTRACT: A short-lived singleton for Bread::Board
5 2 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 our $VERSION = 'v0.900.1'; # VERSION
7  
8 2 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Module::Runtime ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 our $FLUSHER_ROLE = 'Bread::Board::Container::Role::WithSessions';
13  
14 2 with 'Bread::Board::LifeCycle::Singleton';
15  
16 ### XXX: Lifecycle consumption happens after service construction,
17 ### so we have pick a method that would get called after
18 ### construction. The 'get' method is pretty hot, so this should
19 ### be done as fast as possible.
20  
21 6 ▶before get => sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
22 6 my $self = shift;
23  
24 # Assume we've already done this if an instance exists
25 6 ▶ return if $self->has_instance;
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_instance 0 6 6
26  
27 6 Module::Runtime::require_module($FLUSHER_ROLE);
28  
29 6 my @containers = ($self->get_root_container);
30  
31 # Traverse the sub containers and apply the WithSessions role
32 6 ▶ while (my $container = shift @containers) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $container = shift @containers) 6 6 12
33 6 push @containers, values %{$container->sub_containers};
34  
35 6 ▶ Class::MOP::class_of($FLUSHER_ROLE)->apply($container)
Branch: 1 branch
BranchTrueFalseTotal
unless $container->meta->does_role($Bread::Board::LifeCycle::Session::FLUSHER_ROLE) 1 5 6
36 unless $container->meta->does_role($FLUSHER_ROLE);
37 }
38 2 };
39  
40 2 1;
41  
42 __END__
« LifeCycle/Session/WithParameters.pm ↑ Summary