X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FTypeConstraint%2FParameterized.pm;h=68dc7f6e5e0baefe5411a7486aedbb9dc5a22936;hb=a532c4ac93ebdcbd09cd455dbb49caf8a7de1912;hp=a7d45ae873f6f9a9e2d3c352bd7ae9ac19e4a033;hpb=eaa35e6e0f9132abf6ed0cec60515dd7259ce704;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/TypeConstraint/Parameterized.pm b/lib/Moose/Meta/TypeConstraint/Parameterized.pm index a7d45ae..68dc7f6 100644 --- a/lib/Moose/Meta/TypeConstraint/Parameterized.pm +++ b/lib/Moose/Meta/TypeConstraint/Parameterized.pm @@ -5,10 +5,11 @@ use warnings; use metaclass; use Scalar::Util 'blessed'; -use Carp 'confess'; use Moose::Util::TypeConstraints; +use Moose::Meta::TypeConstraint::Parameterizable; -our $VERSION = '0.50'; +our $VERSION = '0.71_01'; +$VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; use base 'Moose::Meta::TypeConstraint'; @@ -35,13 +36,17 @@ sub equals { sub compile_type_constraint { my $self = shift; - ($self->has_type_parameter) - || confess "You cannot create a Higher Order type without a type parameter"; - + unless ( $self->has_type_parameter ) { + require Moose; + Moose->throw_error("You cannot create a Higher Order type without a type parameter"); + } + my $type_parameter = $self->type_parameter; - (blessed $type_parameter && $type_parameter->isa('Moose::Meta::TypeConstraint')) - || confess "The type parameter must be a Moose meta type"; + unless ( blessed $type_parameter && $type_parameter->isa('Moose::Meta::TypeConstraint') ) { + require Moose; + Moose->throw_error("The type parameter must be a Moose meta type"); + } foreach my $type (Moose::Util::TypeConstraints::get_all_parameterizable_types()) { if (my $constraint = $type->generate_constraint_for($self)) { @@ -52,8 +57,14 @@ sub compile_type_constraint { # if we get here, then we couldn't # find a way to parameterize this type - confess "The " . $self->name . " constraint cannot be used, because " - . $self->parent->name . " doesn't subtype or coerce from a parameterizable type."; + require Moose; + Moose->throw_error("The " . $self->name . " constraint cannot be used, because " + . $self->parent->name . " doesn't subtype or coerce from a parameterizable type."); +} + +sub create_child_type { + my ($self, %opts) = @_; + return Moose::Meta::TypeConstraint::Parameterizable->new(%opts, parent=>$self); } 1; @@ -81,6 +92,8 @@ Moose::Meta::TypeConstraint::Parameterized - Higher Order type constraints for M =item B +=item B + =back =head1 BUGS @@ -95,7 +108,7 @@ Stevan Little Estevan@iinteractive.comE =head1 COPYRIGHT AND LICENSE -Copyright 2006-2008 by Infinity Interactive, Inc. +Copyright 2006-2009 by Infinity Interactive, Inc. L