From: Jesse Luehrs Date: Sun, 26 Sep 2010 02:34:42 +0000 (-0500) Subject: first stab (this really needs some work) X-Git-Tag: 2.0300~34 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=510d13e10d45339637e19fe365354fa45963fec0;p=gitmo%2FMoose.git first stab (this really needs some work) --- diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index 0b7dccf..c436d61 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -163,7 +163,9 @@ sub create_class_type_constraint { $options{name} ||= "__ANON__"; - Moose::Meta::TypeConstraint::Class->new(%options); + my $tc = Moose::Meta::TypeConstraint::Class->new(%options); + $REGISTRY->add_type_constraint($tc); + return $tc; } sub create_role_type_constraint { @@ -181,7 +183,9 @@ sub create_role_type_constraint { $options{name} ||= "__ANON__"; - Moose::Meta::TypeConstraint::Role->new(%options); + my $tc = Moose::Meta::TypeConstraint::Role->new(%options); + $REGISTRY->add_type_constraint($tc); + return $tc; } sub find_or_create_type_constraint { @@ -323,21 +327,11 @@ sub subtype { } sub class_type { - register_type_constraint( - create_class_type_constraint( - $_[0], - ( defined( $_[1] ) ? $_[1] : () ), - ) - ); + create_class_type_constraint(@_); } sub role_type ($;$) { - register_type_constraint( - create_role_type_constraint( - $_[0], - ( defined( $_[1] ) ? $_[1] : () ), - ) - ); + create_role_type_constraint(@_); } sub maybe_type {