From: Dave Rolsky Date: Fri, 15 Apr 2011 15:37:21 +0000 (-0500) Subject: Explicitly set the constraint for role type X-Git-Tag: 2.0100~70 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7ae2d9331a652e701aa4cf8e8b0e8acb558b1286;p=gitmo%2FMoose.git Explicitly set the constraint for role type --- diff --git a/lib/Moose/Meta/TypeConstraint/Role.pm b/lib/Moose/Meta/TypeConstraint/Role.pm index b8e375a..51951b1 100644 --- a/lib/Moose/Meta/TypeConstraint/Role.pm +++ b/lib/Moose/Meta/TypeConstraint/Role.pm @@ -17,7 +17,11 @@ sub new { my ( $class, %args ) = @_; $args{parent} = Moose::Util::TypeConstraints::find_type_constraint('Object'); - my $self = $class->_new(\%args); + + my $role_name = $args{role}; + $args{constraint} = sub { Moose::Util::does_role( $_[0], $role_name ) }; + + my $self = $class->_new( \%args ); $self->_create_hand_optimized_type_constraint; $self->compile_type_constraint();