X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FTypeCoercion%2FUnion.pm;h=753b67e761b9371490687c405f16de21a4c7d631;hb=113d3174264db82cb788bc846f617584072cba39;hp=a3d349d55aeef051bff967c116bedd03e54c9b1b;hpb=88463309ede3e9d6a395395ce0d6f1f5ae29cca6;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/TypeCoercion/Union.pm b/lib/Moose/Meta/TypeCoercion/Union.pm index a3d349d..753b67e 100644 --- a/lib/Moose/Meta/TypeCoercion/Union.pm +++ b/lib/Moose/Meta/TypeCoercion/Union.pm @@ -7,7 +7,7 @@ use metaclass; use Scalar::Util 'blessed'; -our $VERSION = '0.72'; +our $VERSION = '0.91'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -16,27 +16,27 @@ use base 'Moose::Meta::TypeCoercion'; sub compile_type_coercion { my $self = shift; my $type_constraint = $self->type_constraint; - + (blessed $type_constraint && $type_constraint->isa('Moose::Meta::TypeConstraint::Union')) || Moose->throw_error("You can only a Moose::Meta::TypeCoercion::Union for a " . "Moose::Meta::TypeConstraint::Union, not a $type_constraint"); - + $self->_compiled_type_coercion(sub { my $value = shift; - # go through all the type constraints + # go through all the type constraints # in the union, and check em ... foreach my $type (@{$type_constraint->type_constraints}) { # if they have a coercion first - if ($type->has_coercion) { + if ($type->has_coercion) { # then try to coerce them ... my $temp = $type->coerce($value); - # and if they get something + # and if they get something # make sure it still fits within # the union type ... return $temp if $type_constraint->check($temp); } } - return undef; + return undef; }); } @@ -72,7 +72,7 @@ This method always returns false. =item B<< $coercion->add_type_coercions >> This method always throws an error. You cannot add coercions to a -union type constraint. +union type coercion. =item B<< $coercion->coerce($value) >> @@ -83,7 +83,7 @@ union. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. @@ -98,6 +98,6 @@ Copyright 2006-2009 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. +it under the same terms as Perl itself. =cut