Chloro/Trait/Application/ToClass.pm

filter: Statementstmt 100% 37 / 37 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 96.1% 50 / 52 CC 7 SCAR 11.1
CC
7
Cov
96%
_apply_form_components
5.1
__ANON__
3.0
BEGIN
1.0
CRAP 3.0
« Chloro/Trait/Class.pm ↑ Summary Chloro/Role/Trait/HasFormComponents.pm »
1 package Chloro::Trait::Application::ToClass;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '0.07';
8  
9 1 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use Moose::Util qw( does_role );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 with 'Chloro::Trait::Application';
14  
15 4 ▶around apply => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
16 4 my $orig = shift;
17 4 my $self = shift;
18 4 my $role = shift;
19 4 my $class = shift;
20  
21 4 ▶ unless ( does_role( $class, 'Chloro::Trait::Class' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (does_role($class, "Chloro::Trait::Class")) 3 1 4
22 3 $class = Moose::Util::MetaRole::apply_metaroles(
23 for => $class,
24 class_metaroles => {
25 class => ['Chloro::Trait::Class'],
26 },
27 );
28 }
29  
30 4 ▶ unless ( $class->does_role('Chloro::Role::Form') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($class->does_role("Chloro::Role::Form")) 3 1 4
31 3 Moose::Util::MetaRole::apply_base_class_roles(
32 for => $class,
33 roles => ['Chloro::Role::Form'],
34 );
35 }
36  
37 4 $self->$orig( $role, $class );
38 1 };
39  
40 ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines)
41 4 ▶sub _apply_form_components {
Subroutine _apply_form_components: called CC=5 SCAR=16.3
42 4 my $self = shift;
43 4 my $role = shift;
44 4 my $class = shift;
45  
46 4 foreach my $field ( $role->fields() ) {
47 5 ▶ next if $class->has_field( $field->name() );
Branch: 1 branch
BranchTrueFalseTotal
if $class->has_field($field->name) 0 5 5
48  
49 5 $class->add_field($field);
50 }
51  
52 4 foreach my $group ( $role->groups() ) {
53 5 ▶ next if $class->has_group( $group->name() );
Branch: 1 branch
BranchTrueFalseTotal
if $class->has_group($group->name) 0 5 5
54  
55 5 $class->add_group($group);
56 }
57 }
58 ## use critic
59  
60 1 1;
61  
62 # ABSTRACT: A trait that supports applying Chloro fields and groups to classes
63  
64 __END__
« Chloro/Trait/Class.pm ↑ Summary Chloro/Role/Trait/HasFormComponents.pm »