| 1 | ## no critic (Moose::RequireMakeImmutable) | ||||||||||
| 2 | package Chloro::Trait::Application::ToRole; | ||||||||||
| 3 | |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | our $VERSION = '0.07'; | |||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 1 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 1 | with 'Chloro::Trait::Application'; | |||||||||
| 15 | |||||||||||
| 16 | 0 | ▶ | around apply => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||
| 17 | 0 | my $orig = shift; | |||||||||
| 18 | 0 | my $self = shift; | |||||||||
| 19 | 0 | my $role1 = shift; | |||||||||
| 20 | 0 | my $role2 = shift; | |||||||||
| 21 | |||||||||||
| 22 | 0 | ▶ | unless ( does_role( $role2, 'Chloro::Trait::Role' ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 0 | $role2 = Moose::Util::MetaRole::apply_metaroles( | |||||||||
| 24 | for => $role2, | ||||||||||
| 25 | role_metaroles => { | ||||||||||
| 26 | role => ['Chloro::Trait::Role'], | ||||||||||
| 27 | application_to_class => | ||||||||||
| 28 | ['Chloro::Trait::Application::ToClass'], | ||||||||||
| 29 | application_to_role => ['Chloro::Trait::Application::ToRole'], | ||||||||||
| 30 | }, | ||||||||||
| 31 | ); | ||||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 0 | $self->$orig( $role1, $role2 ); | |||||||||
| 35 | 1 | }; | |||||||||
| 36 | |||||||||||
| 37 | ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||
| 38 | 0 | ▶ | sub _apply_form_components { | ||||||||
|
Subroutine
_apply_form_components: not called CC=5 SCAR=34.0
| |||||||||||
| 39 | 0 | my $self = shift; | |||||||||
| 40 | 0 | my $role1 = shift; | |||||||||
| 41 | 0 | my $role2 = shift; | |||||||||
| 42 | |||||||||||
| 43 | 0 | foreach my $field ( $role1->fields() ) { | |||||||||
| 44 | 0 | ▶ | if ( $role2->has_field( $field->name() ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | |||||||||||
| 46 | 0 | require Moose; | |||||||||
| 47 | 0 | Moose->throw_error( q{Role '} | |||||||||
| 48 | . $role1->name() | ||||||||||
| 49 | . q{' has encountered a field conflict } | ||||||||||
| 50 | . 'during composition. This is fatal error and cannot be disambiguated.' | ||||||||||
| 51 | ); | ||||||||||
| 52 | } | ||||||||||
| 53 | else { | ||||||||||
| 54 | 0 | $role2->add_field($field); | |||||||||
| 55 | } | ||||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | 0 | foreach my $group ( $role1->groups() ) { | |||||||||
| 59 | 0 | ▶ | if ( $role2->has_group( $group->name() ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | |||||||||||
| 61 | 0 | require Moose; | |||||||||
| 62 | 0 | Moose->throw_error( q{Role '} | |||||||||
| 63 | . $role1->name() | ||||||||||
| 64 | . q{' has encountered a group conflict } | ||||||||||
| 65 | . 'during composition. This is fatal error and cannot be disambiguated.' | ||||||||||
| 66 | ); | ||||||||||
| 67 | } | ||||||||||
| 68 | else { | ||||||||||
| 69 | 0 | $role2->add_group($group); | |||||||||
| 70 | } | ||||||||||
| 71 | } | ||||||||||
| 72 | } | ||||||||||
| 73 | ## use critic | ||||||||||
| 74 | |||||||||||
| 75 | 1 | 1; | |||||||||
| 76 | |||||||||||
| 77 | # ABSTRACT: A trait that supports applying Chloro fields and groups to roles | ||||||||||
| 78 | |||||||||||
| 79 | __END__ | ||||||||||