| 1 | package MooseX::Configuration::Trait::Attribute::ConfigKey; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | $MooseX::Configuration::Trait::Attribute::ConfigKey::VERSION = '0.02'; | |||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use MooseX::Types::Moose qw( Str ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | has config_section => ( | |||||||||||||||||||||||||||
| 13 | is => 'ro', | ||||||||||||||||||||||||||||
| 14 | isa => Str, | ||||||||||||||||||||||||||||
| 15 | default => q{_}, | ||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | has config_key => ( | |||||||||||||||||||||||||||
| 19 | is => 'ro', | ||||||||||||||||||||||||||||
| 20 | isa => Str, | ||||||||||||||||||||||||||||
| 21 | required => 1, | ||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 1 | has original_default => ( | |||||||||||||||||||||||||||
| 25 | is => 'ro', | ||||||||||||||||||||||||||||
| 26 | isa => Str, | ||||||||||||||||||||||||||||
| 27 | predicate => 'has_original_default', | ||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 4 | ▶ | around _process_options => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||
| 31 | 4 | my $orig = shift; | |||||||||||||||||||||||||||
| 32 | 4 | my ( $class, $name, $options ) = @_; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | $class->throw_error( | ||||||||||||||||||||||||||||
| 35 | 'Cannot define a configuration attribute unless you specify a config key name', | ||||||||||||||||||||||||||||
| 36 | data => $options | ||||||||||||||||||||||||||||
| 37 | 4 | ▶ | ) unless defined $options->{key} && length $options->{key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $options->{"key"} and length $options->{"key"}
MC/DC0%0/2
defined $options->{"key"} and length $options->{"key"}
defined $options->{"key"}
length $options->{"key"}
Truth table33%1/3
A and B
A= defined $options->{"key"}B= length $options->{"key"}
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 4 | $class->$orig( $name, $options ); | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 4 | $class->_process_default_or_builder_option($options); | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | $options->{config_section} = delete $options->{section} | ||||||||||||||||||||||||||||
| 44 | 4 | ▶ | if exists $options->{section}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 4 | $options->{config_key} = delete $options->{key}; | |||||||||||||||||||||||||||
| 46 | 1 | }; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 4 | ▶ | sub _process_default_or_builder_option { | ||||||||||||||||||||||||||
|
Subroutine
_process_default_or_builder_option: called CC=5 SCAR=19.8
| |||||||||||||||||||||||||||||
| 49 | 4 | my $class = shift; | |||||||||||||||||||||||||||
| 50 | 4 | my $options = shift; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 4 | $options->{lazy} = 1; | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 4 | ▶ | my $section = defined $options->{section} ? $options->{section} : q{_}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 4 | my $key = $options->{key}; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 4 | ▶ | if ( exists $options->{default} ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 58 | 2 | my $def = $options->{default}; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 2 | ▶ | if ( ref $options->{default} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | $options->{default} = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 62 | 0 | my $val = $_[0]->_from_config( $section, $key ); | |||||||||||||||||||||||||||
| 63 | 0 | ▶ | return $val if defined $val; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 0 | return $def->( $_[0] ); | |||||||||||||||||||||||||||
| 65 | 0 | }; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | else { | ||||||||||||||||||||||||||||
| 68 | 1 | ▶ | $options->{default} = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||
| 69 | 1 | my $val = $_[0]->_from_config( $section, $key ); | |||||||||||||||||||||||||||
| 70 | 1 | ▶ | return $val if defined $val; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 0 | return $def; | |||||||||||||||||||||||||||
| 72 | 2 | }; | |||||||||||||||||||||||||||
| 73 | 2 | $options->{original_default} = $def; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | elsif ( $options->{builder} ) { | ||||||||||||||||||||||||||||
| 77 | 0 | my $builder = delete $options->{builder}; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | $options->{default} = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 80 | 0 | my $val = $_[0]->_from_config( $section, $key ); | |||||||||||||||||||||||||||
| 81 | 0 | ▶ | return $val if defined $val; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 0 | return $_[0]->$builder(); | |||||||||||||||||||||||||||
| 83 | 0 | }; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | else { | ||||||||||||||||||||||||||||
| 86 | 2 | ▶ | $options->{default} = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 87 | 2 | return $_[0]->_from_config( $section, $key ); | |||||||||||||||||||||||||||
| 88 | 2 | }; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 1 | 1; | |||||||||||||||||||||||||||