X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FUtil%2FTypeConstraints.pm;h=fb657ca04d7ebf6b55997edc9780c5b02af29b33;hb=ddbae99e7b6aab832726f3b7d03d50c7a1cea22b;hp=88f1dd7381a5bcd32f78f55563c9d3264848b731;hpb=6f496445489688cc76b0de61d66ab515f1c608b8;p=gitmo%2FMoose.git diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index 88f1dd7..fb657ca 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -155,7 +155,7 @@ sub create_class_type_constraint { #find_type_constraint("ClassName")->check($class) # || __PACKAGE__->_throw_error("Can't create a class type constraint because '$class' is not a class name"); - my $pkg_defined_in = scalar( caller(1) ); + my $pkg_defined_in = $options->{package_defined_in} || scalar( caller(1) ); if (my $type = $REGISTRY->get_type_constraint($class)) { if (!($type->isa('Moose::Meta::TypeConstraint::Class') && $type->class eq $class)) { @@ -188,7 +188,7 @@ sub create_role_type_constraint { #find_type_constraint("ClassName")->check($class) # || __PACKAGE__->_throw_error("Can't create a class type constraint because '$class' is not a class name"); - my $pkg_defined_in = scalar( caller(1) ); + my $pkg_defined_in = $options->{package_defined_in} || scalar( caller(1) ); if (my $type = $REGISTRY->get_type_constraint($role)) { if (!($type->isa('Moose::Meta::TypeConstraint::Role') && $type->role eq $role)) { @@ -244,15 +244,15 @@ sub find_or_create_type_constraint { } sub find_or_create_isa_type_constraint { - my $type_constraint_name = shift; + my ($type_constraint_name, $options) = @_; find_or_parse_type_constraint($type_constraint_name) - || create_class_type_constraint($type_constraint_name); + || create_class_type_constraint($type_constraint_name, $options); } sub find_or_create_does_type_constraint { - my $type_constraint_name = shift; + my ($type_constraint_name, $options) = @_; find_or_parse_type_constraint($type_constraint_name) - || create_role_type_constraint($type_constraint_name); + || create_role_type_constraint($type_constraint_name, $options); } sub find_or_parse_type_constraint {