X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FTypeCoercion.pm;h=426e2b687bd138b549425abd0ebd04e6e0a83daf;hb=be05faea2de65e890bb91af2f2341f644e95883e;hp=4620c51d3529079d2ff9a9e25265bac56c505234;hpb=6f9ff1af2a8de6a0c55f6cc7aa436bd9c3ad08a6;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/TypeCoercion.pm b/lib/Moose/Meta/TypeCoercion.pm index 4620c51..426e2b6 100644 --- a/lib/Moose/Meta/TypeCoercion.pm +++ b/lib/Moose/Meta/TypeCoercion.pm @@ -10,7 +10,7 @@ use Carp 'confess'; use Moose::Meta::Attribute; use Moose::Util::TypeConstraints (); -our $VERSION = '0.04'; +our $VERSION = '0.50'; our $AUTHORITY = 'cpan:STEVAN'; __PACKAGE__->meta->add_attribute('type_coercion_map' => ( @@ -43,7 +43,7 @@ sub compile_type_coercion { my @coercions; while (@coercion_map) { my ($constraint_name, $action) = splice(@coercion_map, 0, 2); - my $type_constraint = Moose::Util::TypeConstraints::find_type_constraint($constraint_name); + my $type_constraint = ref $constraint_name ? $constraint_name : Moose::Util::TypeConstraints::find_or_parse_type_constraint($constraint_name); (defined $type_constraint) || confess "Could not find the type constraint ($constraint_name) to coerce from"; push @coercions => [ @@ -55,7 +55,7 @@ sub compile_type_coercion { my $thing = shift; foreach my $coercion (@coercions) { my ($constraint, $converter) = @$coercion; - if (defined $constraint->($thing)) { + if ($constraint->($thing)) { local $_ = $thing; return $converter->($thing); } @@ -147,11 +147,11 @@ Stevan Little Estevan@iinteractive.comE =head1 COPYRIGHT AND LICENSE -Copyright 2006, 2007 by Infinity Interactive, Inc. +Copyright 2006-2008 by Infinity Interactive, Inc. L This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. -=cut \ No newline at end of file +=cut