| 1 | |||||||||||||
| 2 | 13 | ▶ | use v5.10; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 13 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 13 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | package Context::Singleton::Frame::Builder::Base; | ||||||||||||
| 7 | 13 | $Context::Singleton::Frame::Builder::Base::VERSION = '1.0.9'; | |||||||||||
| 8 | 13 | ▶ | use List::Util v1.450; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 13 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 13 | ▶ | use namespace::clean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | |||||||||||||
| 13 | has q (_default) | ||||||||||||
| 14 | => is => q (ro) | ||||||||||||
| 15 | => init_arg => q (default) | ||||||||||||
| 16 | 292 | ▶ | => default => sub { +{} } | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 17 | 13 | ; | |||||||||||
| 18 | |||||||||||||
| 19 | 13 | has q (this) | |||||||||||
| 20 | => is => q (ro) | ||||||||||||
| 21 | ; | ||||||||||||
| 22 | |||||||||||||
| 23 | 13 | has q (dep) | |||||||||||
| 24 | => is => q (ro) | ||||||||||||
| 25 | ; | ||||||||||||
| 26 | |||||||||||||
| 27 | 13 | has q (as) | |||||||||||
| 28 | => is => q (ro) | ||||||||||||
| 29 | => predicate => q (has_as) | ||||||||||||
| 30 | ; | ||||||||||||
| 31 | |||||||||||||
| 32 | 13 | has q (call) | |||||||||||
| 33 | => is => q (ro) | ||||||||||||
| 34 | => predicate => q (has_call) | ||||||||||||
| 35 | ; | ||||||||||||
| 36 | |||||||||||||
| 37 | 13 | has q (builder) | |||||||||||
| 38 | => is => q (ro) | ||||||||||||
| 39 | => predicate => q (has_builder) | ||||||||||||
| 40 | ; | ||||||||||||
| 41 | |||||||||||||
| 42 | has q (_required) | ||||||||||||
| 43 | => is => q (ro) | ||||||||||||
| 44 | => init_arg => +undef | ||||||||||||
| 45 | => lazy => 1 | ||||||||||||
| 46 | 219 | ▶ | => default => sub { [ List::Util::uniq $_[0]->_build_required ] } | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 47 | 13 | ; | |||||||||||
| 48 | |||||||||||||
| 49 | 219 | ▶ | sub _build_required { | ||||||||||
|
Subroutine
_build_required: called CC=1 SCAR=0.0
| |||||||||||||
| 50 | 219 | my ($self) = @_; | |||||||||||
| 51 | |||||||||||||
| 52 | 219 | return grep defined, $self->this; | |||||||||||
| 53 | } | ||||||||||||
| 54 | |||||||||||||
| 55 | 1433 | ▶ | sub required { | ||||||||||
|
Subroutine
required: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 56 | 1433 | my ($self) = @_; | |||||||||||
| 57 | |||||||||||||
| 58 | 1433 | return @{ $self->_required }; | |||||||||||
| 59 | } | ||||||||||||
| 60 | |||||||||||||
| 61 | 14 | ▶ | sub unresolved { | ||||||||||
|
Subroutine
unresolved: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||
| 62 | 14 | my ($self, $resolved) = @_; | |||||||||||
| 63 | 14 | my $default = $self->_default; | |||||||||||
| 64 | 14 | ▶ | $resolved //= {}; | ||||||||||
|
Condition50%1/2
$resolved //= {}
MC/DC0%0/1
$resolved //= {}
$resolved
Truth table50%1/2
A
A= $resolved
| |||||||||||||
| 65 | |||||||||||||
| 66 | return | ||||||||||||
| 67 | grep ! exists $default->{$_}, | ||||||||||||
| 68 | 14 | grep ! exists $resolved->{$_}, | |||||||||||
| 69 | $self->required | ||||||||||||
| 70 | ; | ||||||||||||
| 71 | } | ||||||||||||
| 72 | |||||||||||||
| 73 | 1409 | ▶ | sub default { | ||||||||||
|
Subroutine
default: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 74 | 1409 | my ($self) = @_; | |||||||||||
| 75 | |||||||||||||
| 76 | 1409 | return %{ $self->_default }; | |||||||||||
| 77 | } | ||||||||||||
| 78 | |||||||||||||
| 79 | 23 | ▶ | sub build { | ||||||||||
|
Subroutine
build: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||
| 80 | 23 | my ($self, $resolved) = @_; | |||||||||||
| 81 | |||||||||||||
| 82 | 23 | ▶ | $resolved = { %{ $self->_default }, %{ $resolved // {} } }; | ||||||||||
|
Condition50%1/2
$resolved // {}
MC/DC0%0/1
$resolved // {}
$resolved
Truth table50%1/2
A
A= $resolved
| |||||||||||||
| 83 | 23 | my @args = $self->build_callback_args ($resolved); | |||||||||||
| 84 | |||||||||||||
| 85 | 23 | ▶ | return $self->as->(@args) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 86 | if $self->has_as | ||||||||||||
| 87 | ; | ||||||||||||
| 88 | |||||||||||||
| 89 | 2 | my $this = shift @args; | |||||||||||
| 90 | |||||||||||||
| 91 | 2 | ▶ | return $this->can ($self->call)->(@args) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 92 | if $self->has_call | ||||||||||||
| 93 | ; | ||||||||||||
| 94 | |||||||||||||
| 95 | 1 | return $this->${\ $self->builder } (@args); | |||||||||||
| 96 | } | ||||||||||||
| 97 | |||||||||||||
| 98 | 35 | ▶ | sub build_callback_args { | ||||||||||
|
Subroutine
build_callback_args: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 99 | 35 | my ($self, $resolved) = @_; | |||||||||||
| 100 | |||||||||||||
| 101 | 35 | return map $resolved->{$_}, grep $_, $self->this; | |||||||||||
| 102 | } | ||||||||||||
| 103 | |||||||||||||
| 104 | 13 | 1; | |||||||||||
| 105 | |||||||||||||
| 106 | __END__ | ||||||||||||