| 1 | 441 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | package HTML::FormFu::Role::CustomRoles; | ||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: add custom roles | ||||||||||||||||||||||||||||||||
| 5 | 441 | $HTML::FormFu::Role::CustomRoles::VERSION = '2.09'; | |||||||||||||||||||||||||||||||
| 6 | 441 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 441 | ▶ | use Moose::Util qw( ensure_all_roles ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | 441 | ▶ | use List::Util 1.45 qw( uniq ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | has _roles => ( | ||||||||||||||||||||||||||||||||
| 12 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | 441 | lazy => 1, | |||||||||||||||||||||||||||||||
| 15 | isa => 'ArrayRef', | ||||||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | sub roles { | ||||||||||||||||||||||||||||||
|
Subroutine
roles: called CC=9 SCAR=26.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 19 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | 3 | my @roles = @{ $self->_roles }; | |||||||||||||||||||||||||||||||
| 22 | 3 | my @new; | |||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | 3 | ▶ | if ( 1 == @_ && 'ARRAY' eq ref $_[0] ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
1 == @_ and "ARRAY" eq ref $_[0]
MC/DC0%0/2
1 == @_ and "ARRAY" eq ref $_[0]
1 == @_
"ARRAY" eq ref $_[0]
Truth table33%1/3
A and B
A= 1 == @_B= "ARRAY" eq ref $_[0]
| |||||||||||||||||||||||||||||||||
| 25 | 3 | @new = @{ $_[0] }; | |||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||
| 27 | elsif (@_) { | ||||||||||||||||||||||||||||||||
| 28 | 0 | @new = @_; | |||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | 3 | ▶ | if (@new) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 32 | 3 | for my $role (@new) { | |||||||||||||||||||||||||||||||
| 33 | 3 | ▶ | if ( !ref($role) && $role =~ s/^\+// ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
not ref $role and $role =~ s/^\+//
MC/DC0%0/2
not ref $role and $role =~ s/^\+//
not ref $role
$role =~ s/^\+//
Truth table33%1/3
not(A) and B
A= not ref $roleB= $role =~ s/^\+//
| |||||||||||||||||||||||||||||||||
| 34 | 3 | push @roles, $role; | |||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||
| 36 | elsif ( !ref $role ) { | ||||||||||||||||||||||||||||||||
| 37 | 0 | push @roles, "HTML::FormFu::Role::$role"; | |||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||
| 39 | else { | ||||||||||||||||||||||||||||||||
| 40 | 0 | push @roles, $role; | |||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | 3 | @roles = uniq @roles; | |||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 3 | ensure_all_roles( $self, @roles ); | |||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | 3 | $self->_roles( \@roles ); | |||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | 3 | return [@roles]; | |||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | 441 | 1; | |||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | __END__ | ||||||||||||||||||||||||||||||||