| 1 | package Bread::Board::Service::WithConstructor; | ||||||||||||||||||||||||||||
| 2 | 67 | our $AUTHORITY = 'cpan:STEVAN'; | |||||||||||||||||||||||||||
| 3 | 67 | $Bread::Board::Service::WithConstructor::VERSION = '0.37'; | |||||||||||||||||||||||||||
| 4 | 67 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 67 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 67 | with 'Bread::Board::Service::WithClass'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 67 | has 'constructor_name' => ( | |||||||||||||||||||||||||||
| 11 | is => 'rw', | ||||||||||||||||||||||||||||
| 12 | isa => 'Str', | ||||||||||||||||||||||||||||
| 13 | lazy => 1, | ||||||||||||||||||||||||||||
| 14 | builder => '_build_constructor_name', | ||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 121 | ▶ | sub _build_constructor_name { | ||||||||||||||||||||||||||
|
Subroutine
_build_constructor_name: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||
| 18 | 121 | my $self = shift; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | # using Class::MOP::class_of on a Moo | ||||||||||||||||||||||||||||
| 21 | # object causes mayhem, so we take care of that | ||||||||||||||||||||||||||||
| 22 | # special case first. See GH#61 | ||||||||||||||||||||||||||||
| 23 | 121 | ▶ | try { $self->class->isa('Moo::Object') && 'new' } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 118 | ▶ | || try { Class::MOP::class_of($self->class)->constructor_name } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 121 | ▶ | || 'new'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
&try(sub {
$self->class->isa("Moo::Object") and "new";
}
) or &try(sub {
Class::MOP::class_of($self->class)->constructor_name;
}
)
MC/DC0%0/2
&try(sub {
$self->class->isa("Moo::Object") and "new";
}
) or &try(sub {
Class::MOP::class_of($self->class)->constructor_name;
}
)
&try(sub {
$self->class->isa("Moo::Object") and "new";
}
)
&try(sub {
Class::MOP::class_of($self->class)->constructor_name;
}
)
Truth table66%2/3
A or B
A= &try(sub {
$self->class->isa("Moo::Object") and "new";
}
)B= &try(sub {
Class::MOP::class_of($self->class)->constructor_name;
}
)
| |||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 67 | ▶ | no Moose; 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | __END__ | ||||||||||||||||||||||||||||