DeclareX/Registry.pm

filter: Statementstmt 65.7% 25 / 38 Branchbran 0.0% 0 / 6 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 77.7% 7 / 9 Podpod 0.0% 0 / 2 totaltotal 56.9% 33 / 58 CC 6 SCAR 13.9
CC
6
Cov
57%
__ANON__
6.6
register_option
6.0
register_feature
6.0
CRAP 4.0
« DeclareX.pm ↑ Summary DeclareX/Plugin/build.pm »
1 package MooseX::DeclareX::Registry;
2  
3 8 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 $MooseX::DeclareX::Registry::AUTHORITY = 'cpan:TOBYINK';
5 8 $MooseX::DeclareX::Registry::VERSION = '0.009';
6 }
7  
8 8 our %context_allow_options;
9  
10 BEGIN
11 8 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
12 8 require MooseX::Declare;
13 }
14  
15 8 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 has registered_features => (
18 is => 'ro',
19 isa => 'HashRef',
20 68 ▶ default => sub {{}},
Subroutine __ANON__: called CC=1 SCAR=0.0
21 8 );
22  
23 has registered_options => (
24 is => 'ro',
25 isa => 'HashRef',
26 68 ▶ default => sub {{}},
Subroutine __ANON__: called CC=1 SCAR=0.0
27 8 );
28  
29 sub register_option
30 0 ▶{
Subroutine register_option: not called CC=2 SCAR=17.9
Pod undocumented
31 0 my ($self, $option, $callback) = @_;
32 0 ▶ return if exists $self->registered_options->{$option};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->registered_options->{$option} 0 0 0
33 0 $self->registered_options->{$option} = $callback;
34 0 $self->meta->add_method("add_${option}_option_customizations", $callback);
35 0 $context_allow_options{$option} = 1;
36 0 return 1;
37 }
38  
39 sub register_feature
40 0 ▶{
Subroutine register_feature: not called CC=2 SCAR=17.9
Pod undocumented
41 0 my ($self, $feature, $callback) = @_;
42 0 ▶ return if exists $self->registered_features->{$feature};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->registered_features->{$feature} 0 0 0
43 0 $self->registered_features->{$feature} = $callback;
44 0 return 1;
45 }
46  
47 8 requires 'add_optional_customizations';
48 before add_optional_customizations => sub
49 15 ▶{
Subroutine __ANON__: called CC=4 SCAR=18.9
50 15 my ($self, $ctx, $package) = @_;
51
52 15 ▶ my %features = %{ $self->registered_features // {} };
Condition50%1/2
$self->registered_features // {}
l!l
150
MC/DC0%0/1
$self->registered_features // {}
$self->registered_features
Truth table50%1/2
A
A= $self->registered_features
Aresult
11
00
53 15 foreach my $f (sort keys %features)
54 {
55 0 ▶ if (exists $ctx->options->{is}{$f})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ctx->options->{"is"}{$f}) 0 0 0
56 {
57 0 my $code = $features{$f};
58 0 $code->($self, $ctx, $package);
59 }
60 }
61 8 };
62  
63 8 requires 'context_traits';
64 15 ▶around context_traits => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
65 15 my $orig = shift;
66 15 my $self = shift;
67 15 my @traits = $self->$orig();
68 15 push @traits, 'MooseX::DeclareX::RegistryUsing';
69 15 return @traits;
70 8 };
71  
72 8 1;
« DeclareX.pm ↑ Summary DeclareX/Plugin/build.pm »