| 1 | package CatalystX::ComponentsFromConfig::Role::PluginRole; | ||||||||||||||||||||||||||||||||||||||
| 2 | 1 | $CatalystX::ComponentsFromConfig::Role::PluginRole::VERSION = '1.006'; | |||||||||||||||||||||||||||||||||||||
| 3 | { | ||||||||||||||||||||||||||||||||||||||
| 4 | 1 | $CatalystX::ComponentsFromConfig::Role::PluginRole::DIST = 'CatalystX-ComponentsFromConfig'; | |||||||||||||||||||||||||||||||||||||
| 5 | } | ||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use MooseX::Role::Parameterized; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use MooseX::Types::Moose qw/Bool/; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use MooseX::Types::Common::String qw/LowerCaseSimpleStr/; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use CatalystX::InjectComponent; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||
| 12 | # ABSTRACT: parameterised role for plugins to create components from configuration | ||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||
| 15 | 1 | parameter component_type => ( | |||||||||||||||||||||||||||||||||||||
| 16 | isa => LowerCaseSimpleStr, | ||||||||||||||||||||||||||||||||||||||
| 17 | required => 1, | ||||||||||||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||
| 21 | 1 | parameter skip_mvc_renaming => ( | |||||||||||||||||||||||||||||||||||||
| 22 | isa => Bool, | ||||||||||||||||||||||||||||||||||||||
| 23 | default => 0, | ||||||||||||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||
| 27 | 4 | ▶ | role { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||
| 28 | 4 | my $params = shift; | |||||||||||||||||||||||||||||||||||||
| 29 | 4 | my $type = $params->component_type; | |||||||||||||||||||||||||||||||||||||
| 30 | 4 | my $uctype = ucfirst($params->component_type); | |||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||
| 32 | 4 | ▶ | after 'setup_components' => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 33 | 4 | my $method = "_setup_dynamic_$type"; | |||||||||||||||||||||||||||||||||||||
| 34 | 4 | shift->$method(@_); | |||||||||||||||||||||||||||||||||||||
| 35 | 4 | }; | |||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||
| 37 | 2 | ▶ | method "_setup_dynamic_$type" => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=20.4
Subroutine
_setup_dynamic_model: called CC=7 SCAR=20.4
| |||||||||||||||||||||||||||||||||||||||
| 38 | 2 | my ($app) = @_; | |||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||
| 40 | 2 | ▶ | my $plugin_config = $app->config->{"${type}s_from_config"} || {}; | ||||||||||||||||||||||||||||||||||||
|
Condition75%3/4
$app->config->{"${type}s_from_config"} || {}
$app->config->{"${type}s_from_config"} || {}
MC/DC0%0/1
$app->config->{"${type}s_from_config"} || {}
$app->config->{"${type}s_from_config"}
MC/DC100%1/1
$app->config->{"${type}s_from_config"} || {}
$app->config->{"${type}s_from_config"}
Truth table50%1/2
A
A= $app->config->{"${type}s_from_config"}
Truth table100%2/2
A
A= $app->config->{"${type}s_from_config"}
| |||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||
| 42 | 2 | my $prefix = "${uctype}::"; | |||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||
| 44 | my $base_class = $plugin_config->{base_class} || | ||||||||||||||||||||||||||||||||||||||
| 45 | 2 | ▶ | "CatalystX::ComponentsFromConfig::${uctype}Adaptor"; | ||||||||||||||||||||||||||||||||||||
|
Condition75%3/4
$plugin_config->{'base_class'} || "CatalystX::ComponentsFromConfig::${uctype}Adaptor"
$plugin_config->{'base_class'} || "CatalystX::ComponentsFromConfig::${uctype}Adaptor"
MC/DC0%0/1
$plugin_config->{'base_class'} || "CatalystX::ComponentsFromConfig::${uctype}Adaptor"
$plugin_config->{'base_class'}
MC/DC100%1/1
$plugin_config->{'base_class'} || "CatalystX::ComponentsFromConfig::${uctype}Adaptor"
$plugin_config->{'base_class'}
Truth table50%1/2
A
A= $plugin_config->{'base_class'}
Truth table100%2/2
A
A= $plugin_config->{'base_class'}
| |||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||
| 47 | 2 | ▶ | my $config = $app->config || {}; | ||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$app->config || {}
$app->config || {}
MC/DC0%0/1
$app->config || {}
$app->config
MC/DC0%0/1
$app->config || {}
$app->config
Truth table50%1/2
A
A= $app->config
Truth table50%1/2
A
A= $app->config
| |||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||
| 49 | 2 | foreach my $comp_name ( grep { /^\Q$prefix\E/ } keys %$config ) { | |||||||||||||||||||||||||||||||||||||
| 50 | 2 | ▶ | unless ($app->component($comp_name)) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 51 | my $local_base_class = | ||||||||||||||||||||||||||||||||||||||
| 52 | 2 | ▶ | $config->{$comp_name}{base_class} || $base_class; | ||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$config->{$comp_name}{'base_class'} || $base_class
$config->{$comp_name}{'base_class'} || $base_class
MC/DC0%0/2
$config->{$comp_name}{'base_class'} || $base_class
$config->{$comp_name}{'base_class'}
$base_class
MC/DC0%0/2
$config->{$comp_name}{'base_class'} || $base_class
$config->{$comp_name}{'base_class'}
$base_class
Truth table33%1/3
A || B
A= $config->{$comp_name}{'base_class'}B= $base_class
Truth table33%1/3
A || B
A= $config->{$comp_name}{'base_class'}B= $base_class
| |||||||||||||||||||||||||||||||||||||||
| 53 | 2 | CatalystX::InjectComponent->inject( | |||||||||||||||||||||||||||||||||||||
| 54 | skip_mvc_renaming => $params->skip_mvc_renaming, | ||||||||||||||||||||||||||||||||||||||
| 55 | into => $app, | ||||||||||||||||||||||||||||||||||||||
| 56 | component => $local_base_class, | ||||||||||||||||||||||||||||||||||||||
| 57 | as => $comp_name, | ||||||||||||||||||||||||||||||||||||||
| 58 | ); | ||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||
| 61 | 4 | }; | |||||||||||||||||||||||||||||||||||||
| 62 | 1 | }; | |||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||
| 64 | 1 | 1; | |||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||
| 66 | __END__ | ||||||||||||||||||||||||||||||||||||||