| 1 | 117 | ▶ | use 5.010001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 117 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 117 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package Mite::Trait::HasRoles; | ||||||||||||||||||||||||||||
| 6 | 117 | ▶ | use Mite::Miteception -role, -all; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 117 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||
| 9 | 117 | our $VERSION = '0.013000'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 117 | requires qw( | |||||||||||||||||||||||||||
| 12 | source | ||||||||||||||||||||||||||||
| 13 | native_methods | ||||||||||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | has roles => | ||||||||||||||||||||||||||||
| 17 | is => rw, | ||||||||||||||||||||||||||||
| 18 | isa => ArrayRef[MiteRole], | ||||||||||||||||||||||||||||
| 19 | 156 | ▶ | builder => sub { [] }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | has role_args => | ||||||||||||||||||||||||||||
| 22 | is => rw, | ||||||||||||||||||||||||||||
| 23 | isa => Map[ NonEmptyStr, HashRef|Undef ], | ||||||||||||||||||||||||||||
| 24 | 158 | ▶ | builder => sub { {} }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 140 | ▶ | sub methods_to_import_from_roles { | ||||||||||||||||||||||||||
|
Subroutine
methods_to_import_from_roles: called CC=8 SCAR=21.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 140 | my $self = shift; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 140 | my %methods; | |||||||||||||||||||||||||||
| 30 | 140 | for my $role ( @{ $self->roles } ) { | |||||||||||||||||||||||||||
| 31 | 13 | ▶ | my $role_args = $self->role_args->{ $role->name } || {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->role_args->{$role->name} || {}
MC/DC100%1/1
$self->role_args->{$role->name} || {}
$self->role_args->{$role->name}
Truth table100%2/2
A
A= $self->role_args->{$role->name}
| |||||||||||||||||||||||||||||
| 32 | 13 | my %exported = %{ $role->methods_to_export( $role_args ) }; | |||||||||||||||||||||||||||
| 33 | 13 | for my $name ( sort keys %exported ) { | |||||||||||||||||||||||||||
| 34 | 13 | ▶ | if ( defined $methods{$name} and $methods{$name} ne $exported{$name} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $methods{$name} and $methods{$name} ne $exported{$name}
MC/DC0%0/2
defined $methods{$name} and $methods{$name} ne $exported{$name}
defined $methods{$name}
$methods{$name} ne $exported{$name}
Truth table33%1/3
A and B
A= defined $methods{$name}B= $methods{$name} ne $exported{$name}
| |||||||||||||||||||||||||||||
| 35 | croak "Conflict between %s and %s; %s must implement %s\n", | ||||||||||||||||||||||||||||
| 36 | 0 | $methods{$name}, $exported{$name}, $self->name, $name; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | else { | ||||||||||||||||||||||||||||
| 39 | 13 | $methods{$name} = $exported{$name}; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | # This package provides a native version of these | ||||||||||||||||||||||||||||
| 45 | # methods, so don't import. | ||||||||||||||||||||||||||||
| 46 | 140 | my %native = %{ $self->native_methods }; | |||||||||||||||||||||||||||
| 47 | 140 | for my $name ( keys %native ) { | |||||||||||||||||||||||||||
| 48 | 57 | delete $methods{$name}; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | # Never propagate | ||||||||||||||||||||||||||||
| 52 | 140 | delete $methods{$_} for qw( | |||||||||||||||||||||||||||
| 53 | new | ||||||||||||||||||||||||||||
| 54 | DESTROY | ||||||||||||||||||||||||||||
| 55 | DOES | ||||||||||||||||||||||||||||
| 56 | does | ||||||||||||||||||||||||||||
| 57 | __META__ | ||||||||||||||||||||||||||||
| 58 | __FINALIZE_APPLICATION__ | ||||||||||||||||||||||||||||
| 59 | CREATE_CLASS | ||||||||||||||||||||||||||||
| 60 | APPLY_TO | ||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 140 | return \%methods; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 11 | ▶ | sub add_role { | ||||||||||||||||||||||||||
|
Subroutine
add_role: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 67 | 11 | my ( $self, $role ) = @_; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 6 | my @attr = sort { $a->_order <=> $b->_order } | |||||||||||||||||||||||||||
| 70 | 11 | values %{ $role->attributes }; | |||||||||||||||||||||||||||
| 71 | 11 | for my $attr ( @attr ) { | |||||||||||||||||||||||||||
| 72 | $self->add_attribute( $attr ) | ||||||||||||||||||||||||||||
| 73 | 10 | ▶ | unless $self->attributes->{ $attr->name }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | 11 | push @{ $self->roles }, $role; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 11 | return; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 11 | ▶ | sub add_roles_by_name { | ||||||||||||||||||||||||||
|
Subroutine
add_roles_by_name: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 81 | 11 | my ( $self, @names ) = @_; | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 11 | for my $name ( @names ) { | |||||||||||||||||||||||||||
| 84 | 11 | my $role = $self->_get_role( $name ); | |||||||||||||||||||||||||||
| 85 | 11 | $self->add_role( $role ); | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 11 | return; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 11 | ▶ | sub _get_role { | ||||||||||||||||||||||||||
|
Subroutine
_get_role: called CC=7 SCAR=25.7
| |||||||||||||||||||||||||||||
| 92 | 11 | my ( $self, $role_name ) = ( shift, @_ ); | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 11 | my $project = $self->project; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | # See if it's already loaded | ||||||||||||||||||||||||||||
| 97 | 11 | my $role = $project->class($role_name); | |||||||||||||||||||||||||||
| 98 | 11 | ▶ | return $role if $role; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | # If not, try to load it | ||||||||||||||||||||||||||||
| 101 | eval "require $role_name; 1" | ||||||||||||||||||||||||||||
| 102 | 2 | ▶ | or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | 0 | my $file_name = $role_name; | |||||||||||||||||||||||||||
| 104 | 0 | ▶ | if ( my $yuck = $project->_module_fakeout_namespace ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | 0 | $file_name =~ s/$yuck\:://g; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | 0 | $file_name =~ s/::/\//g; | |||||||||||||||||||||||||||
| 108 | 0 | $file_name = "lib/$file_name.pm"; | |||||||||||||||||||||||||||
| 109 | 0 | $project->_load_file( $file_name ); | |||||||||||||||||||||||||||
| 110 | }; | ||||||||||||||||||||||||||||
| 111 | 2 | ▶ | if ( $INC{'Role/Tiny.pm'} and 'Role::Tiny'->is_role( $role_name ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$INC{"Role/Tiny.pm"} and "Role::Tiny"->is_role($role_name)
MC/DC0%0/2
$INC{"Role/Tiny.pm"} and "Role::Tiny"->is_role($role_name)
$INC{"Role/Tiny.pm"}
"Role::Tiny"->is_role($role_name)
Truth table33%1/3
A and B
A= $INC{"Role/Tiny.pm"}B= "Role::Tiny"->is_role($role_name)
| |||||||||||||||||||||||||||||
| 112 | 2 | require Mite::Role::Tiny; | |||||||||||||||||||||||||||
| 113 | 2 | $role = 'Mite::Role::Tiny'->inhale( $role_name ); | |||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | else { | ||||||||||||||||||||||||||||
| 116 | 0 | $role = $project->class( $role_name, 'Mite::Role' ); | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | 2 | ▶ | return $role if $role; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 0 | croak <<"ERROR", $role_name; | |||||||||||||||||||||||||||
| 121 | %s loaded but is not a recognized role. Mite roles and Role::Tiny | ||||||||||||||||||||||||||||
| 122 | roles are the only supported roles. Sorry. | ||||||||||||||||||||||||||||
| 123 | ERROR | ||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 24 | ▶ | sub does_list { | ||||||||||||||||||||||||||
|
Subroutine
does_list: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 127 | 24 | my $self = shift; | |||||||||||||||||||||||||||
| 128 | return ( | ||||||||||||||||||||||||||||
| 129 | $self->name, | ||||||||||||||||||||||||||||
| 130 | 24 | map( $_->does_list, @{ $self->roles } ), | |||||||||||||||||||||||||||
| 131 | ); | ||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 11 | ▶ | sub handle_with_keyword { | ||||||||||||||||||||||||||
|
Subroutine
handle_with_keyword: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 135 | 11 | my $self = shift; | |||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 11 | ▶ | while ( @_ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 11 | my $role = shift; | |||||||||||||||||||||||||||
| 139 | 11 | ▶ | my $args = Str->check( $_[0] ) ? undef : shift; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | 11 | $self->role_args->{$role} = $args; | |||||||||||||||||||||||||||
| 141 | 11 | $self->add_roles_by_name( $role ); | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 11 | return; | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 119 | ▶ | before inject_mite_functions => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||
| 148 | 119 | my ( $self, $file, $arg ) = ( shift, @_ ); | |||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 119 | ▶ | my $requested = sub { $arg->{$_[0]} ? 1 : $arg->{'!'.$_[0]} ? 0 : $arg->{'-all'} ? 1 : $_[1]; }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.5
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 151 | 119 | my $defaults = ! $arg->{'!-defaults'}; | |||||||||||||||||||||||||||
| 152 | 119 | my $shim = $self->shim_name; | |||||||||||||||||||||||||||
| 153 | 119 | my $package = $self->name; | |||||||||||||||||||||||||||
| 154 | 119 | ▶ | my $fake_ns = $self->project->can('_module_fakeout_namespace') && $self->project->_module_fakeout_namespace; | ||||||||||||||||||||||||||
|
Condition33%1/3
$self->project->can('_module_fakeout_namespace') && $self->project->_module_fakeout_namespace
MC/DC0%0/2
$self->project->can('_module_fakeout_namespace') && $self->project->_module_fakeout_namespace
$self->project->can('_module_fakeout_namespace')
$self->project->_module_fakeout_namespace
Truth table33%1/3
A && B
A= $self->project->can('_module_fakeout_namespace')B= $self->project->_module_fakeout_namespace
| |||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 117 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 119 | ▶ | if ( $requested->( 'with', $defaults ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 118 | ▶ | *{ $package .'::with' } = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||
| 161 | 11 | ▶ | return $self->handle_with_keyword( | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 162 | defined( $fake_ns ) | ||||||||||||||||||||||||||||
| 163 | ? ( map Str->check($_) ? "$fake_ns\::$_" : $_, @_ ) | ||||||||||||||||||||||||||||
| 164 | : @_ | ||||||||||||||||||||||||||||
| 165 | ); | ||||||||||||||||||||||||||||
| 166 | 118 | }; | |||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 118 | $self->imported_keywords->{with} = 'sub { $SHIM->HANDLE_with( $CALLER, @_ ) }'; | |||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | 117 | }; | |||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 128 | ▶ | around compilation_stages => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 173 | 128 | my ( $next, $self ) = ( shift, shift ); | |||||||||||||||||||||||||||
| 174 | 128 | my @stages = $self->$next( @_ ); | |||||||||||||||||||||||||||
| 175 | 128 | push @stages, qw( | |||||||||||||||||||||||||||
| 176 | _compile_with | ||||||||||||||||||||||||||||
| 177 | _compile_does | ||||||||||||||||||||||||||||
| 178 | _compile_composed_methods | ||||||||||||||||||||||||||||
| 179 | ); | ||||||||||||||||||||||||||||
| 180 | 128 | return @stages; | |||||||||||||||||||||||||||
| 181 | 117 | }; | |||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 128 | ▶ | sub _compile_with { | ||||||||||||||||||||||||||
|
Subroutine
_compile_with: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||
| 184 | 128 | my $self = shift; | |||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 128 | my $roles = [ map $_->name, @{ $self->roles } ]; | |||||||||||||||||||||||||||
| 187 | 128 | ▶ | return unless @$roles; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 11 | my $source = $self->source; | |||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | my $require_list = join "\n\t", | ||||||||||||||||||||||||||||
| 192 | 2 | map { "require $_;" } | |||||||||||||||||||||||||||
| 193 | # Don't require a role from the same source | ||||||||||||||||||||||||||||
| 194 | 11 | ▶ | grep { !$source || !$source->has_class($_) } | ||||||||||||||||||||||||||
|
Condition66%2/3
$source && $source->has_class($_)
MC/DC50%1/2
$source && $source->has_class($_)
$source
$source->has_class($_)
Truth table66%2/3
A && B
A= $sourceB= $source->has_class($_)
| |||||||||||||||||||||||||||||
| 195 | @$roles; | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | my $version_tests = join "\n\t", | ||||||||||||||||||||||||||||
| 198 | map { sprintf '%s->VERSION( %s );', | ||||||||||||||||||||||||||||
| 199 | B::perlstring( $_ ), | ||||||||||||||||||||||||||||
| 200 | 0 | B::perlstring( $self->role_args->{$_}{'-version'} ) | |||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | grep { | ||||||||||||||||||||||||||||
| 203 | 11 | $self->role_args->{$_} | |||||||||||||||||||||||||||
| 204 | 11 | ▶ | and $self->role_args->{$_}{'-version'} | ||||||||||||||||||||||||||
|
Condition66%2/3
$self->role_args->{$_} && $self->role_args->{$_}{'-version'}
MC/DC0%0/2
$self->role_args->{$_} && $self->role_args->{$_}{'-version'}
$self->role_args->{$_}
$self->role_args->{$_}{'-version'}
Truth table66%2/3
A && B
A= $self->role_args->{$_}B= $self->role_args->{$_}{'-version'}
| |||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | @$roles; | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 11 | my $does_hash = join ", ", map sprintf( "%s => 1", B::perlstring($_) ), $self->does_list; | |||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 11 | return <<"END"; | |||||||||||||||||||||||||||
| 211 | BEGIN { | ||||||||||||||||||||||||||||
| 212 | $require_list | ||||||||||||||||||||||||||||
| 213 | $version_tests | ||||||||||||||||||||||||||||
| 214 | our \%DOES = ( $does_hash ); | ||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | END | ||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | 128 | ▶ | sub _compile_does { | ||||||||||||||||||||||||||
|
Subroutine
_compile_does: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 220 | 128 | my $self = shift; | |||||||||||||||||||||||||||
| 221 | return <<'CODE' | ||||||||||||||||||||||||||||
| 222 | # See UNIVERSAL | ||||||||||||||||||||||||||||
| 223 | sub DOES { | ||||||||||||||||||||||||||||
| 224 | my ( $self, $role ) = @_; | ||||||||||||||||||||||||||||
| 225 | our %DOES; | ||||||||||||||||||||||||||||
| 226 | return $DOES{$role} if exists $DOES{$role}; | ||||||||||||||||||||||||||||
| 227 | return 1 if $role eq __PACKAGE__; | ||||||||||||||||||||||||||||
| 228 | if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) { | ||||||||||||||||||||||||||||
| 229 | $meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1; | ||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | return $self->SUPER::DOES( $role ); | ||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | # Alias for Moose/Moo-compatibility | ||||||||||||||||||||||||||||
| 235 | sub does { | ||||||||||||||||||||||||||||
| 236 | shift->DOES( @_ ); | ||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | CODE | ||||||||||||||||||||||||||||
| 239 | 128 | } | |||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 128 | ▶ | sub _compile_composed_methods { | ||||||||||||||||||||||||||
|
Subroutine
_compile_composed_methods: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 242 | 128 | my $self = shift; | |||||||||||||||||||||||||||
| 243 | 128 | my $code = ''; | |||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 128 | my %methods = %{ $self->methods_to_import_from_roles }; | |||||||||||||||||||||||||||
| 246 | 128 | ▶ | keys %methods or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 4 | $code .= "# Methods from roles\n"; | |||||||||||||||||||||||||||
| 249 | 4 | for my $name ( sort keys %methods ) { | |||||||||||||||||||||||||||
| 250 | # Use goto to help namespace::autoclean recognize these as | ||||||||||||||||||||||||||||
| 251 | # not being imported methods. | ||||||||||||||||||||||||||||
| 252 | 7 | $code .= sprintf 'sub %s { goto \&%s; }' . "\n", $name, $methods{$name}; | |||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 4 | return $code; | |||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 0 | ▶ | around _compile_mop_postamble => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 259 | 0 | my ( $next, $self ) = ( shift, shift ); | |||||||||||||||||||||||||||
| 260 | 0 | my $code = $self->$next( @_ ); | |||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 0 | ▶ | my @roles = @{ $self->roles || [] } | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->roles || []
MC/DC0%0/1
$self->roles || []
$self->roles
Truth table0%0/2
A
A= $self->roles
| |||||||||||||||||||||||||||||
| 263 | or return $code; | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 0 | for my $role ( @roles ) { | |||||||||||||||||||||||||||
| 266 | 0 | $code .= sprintf "Moose::Util::find_meta( %s )->add_role( Moose::Util::find_meta( %s ) );\n", | |||||||||||||||||||||||||||
| 267 | B::perlstring( $self->name ), B::perlstring( $role->name ); | ||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | 0 | return $code; | |||||||||||||||||||||||||||
| 271 | 117 | }; | |||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 117 | 1; | |||||||||||||||||||||||||||