foreach my $coercion (@coercions) {
my ($constraint, $converter) = @$coercion;
if (defined $constraint->($thing)) {
- local $_ = $thing;
+ local $_ = $thing;
return $converter->($thing);
}
}
# then we compile them to run without
# having to recurse as we did before
- return subname $self->name => sub {
- local $_ = $_[0];
+ return subname $self->name => sub {
+ local $_ = $_[0];
foreach my $parent (@parents) {
return undef unless $parent->($_[0]);
}
- return undef unless $check->($_[0]);
- 1;
- };
+ return undef unless $check->($_[0]);
+ 1;
+ };
}
sub _compile_type {
my ($self, $check) = @_;
- return subname $self->name => sub {
- local $_ = $_[0];
- return undef unless $check->($_[0]);
- 1;
- };
+ return subname $self->name => sub {
+ local $_ = $_[0];
+ return undef unless $check->($_[0]);
+ 1;
+ };
}
## other utils ...
# the union constraint, which means we need to
# handle this differently.
# - SL
- if (not(defined($check))
+ if (not(defined $check)
&& $parent->isa('Moose::Meta::TypeConstraint::Union')
&& $parent->has_coercion
){
sub _install_type_coercions ($$) {
my ($type_name, $coercion_map) = @_;
my $type = $REGISTRY->get_type_constraint($type_name);
+ (defined $type)
+ || confess "Cannot find type '$type_name', perhaps you forgot to load it.";
if ($type->has_coercion) {
$type->coercion->add_type_coercions(@$coercion_map);
}