« blib/lib/Class/MOP/Method/Accessor.pm
↑ Summary
blib/lib/Moose/Meta/Role/Application/ToInstance.pm »
| 1 | package Moose::Meta::TypeCoercion::Union; | ||||||||||||||||||||||||||||
| 2 | 398 | our $VERSION = '2.4001'; | |||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 398 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 398 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 398 | ▶ | use metaclass; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 398 | ▶ | use Scalar::Util 'blessed'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 398 | ▶ | use parent 'Moose::Meta::TypeCoercion'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 398 | ▶ | use Moose::Util 'throw_exception'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 5 | ▶ | sub compile_type_coercion { | ||||||||||||||||||||||||||
|
Subroutine
compile_type_coercion: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 15 | 5 | my $self = shift; | |||||||||||||||||||||||||||
| 16 | 5 | my $type_constraint = $self->type_constraint; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 5 | ▶ | (blessed $type_constraint && $type_constraint->isa('Moose::Meta::TypeConstraint::Union')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($type_constraint) and $type_constraint->isa("Moose::Meta::TypeConstraint::Union")
MC/DC50%1/2
builtin::blessed($type_constraint) and $type_constraint->isa("Moose::Meta::TypeConstraint::Union")
builtin::blessed($type_constraint)
$type_constraint->isa("Moose::Meta::TypeConstraint::Union")
Truth table66%2/3
A and B
A= builtin::blessed($type_constraint)B= $type_constraint->isa("Moose::Meta::TypeConstraint::Union")
| |||||||||||||||||||||||||||||
| 19 | || throw_exception( NeedsTypeConstraintUnionForTypeCoercionUnion => type_coercion_union_object => $self, | ||||||||||||||||||||||||||||
| 20 | type_name => $type_constraint->name | ||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | $self->_compiled_type_coercion( | ||||||||||||||||||||||||||||
| 24 | 7 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 25 | 7 | my $value = shift; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 7 | foreach my $type ( grep { $_->has_coercion } | |||||||||||||||||||||||||||
| 28 | 7 | @{ $type_constraint->type_constraints } ) { | |||||||||||||||||||||||||||
| 29 | 11 | my $temp = $type->coerce($value); | |||||||||||||||||||||||||||
| 30 | 11 | ▶ | return $temp if $type_constraint->check($temp); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 1 | return $value; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | 4 | ); | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub has_coercion_for_type { 0 } | ||||||||||||||||||||||||||
|
Subroutine
has_coercion_for_type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 1 | ▶ | sub add_type_coercions { | ||||||||||||||||||||||||||
|
Subroutine
add_type_coercions: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 41 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 42 | 1 | throw_exception( CannotAddAdditionalTypeCoercionsToUnion => type_coercion_union_object => $self ); | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 398 | 1; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | # ABSTRACT: The Moose Type Coercion metaclass for Unions | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | __END__ | ||||||||||||||||||||||||||||