From: Shawn M Moore Date: Sat, 28 Mar 2009 20:29:31 +0000 (-0400) Subject: does_role no-meta'ing X-Git-Tag: 0.73_01~36^2~30 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=322abb07081516383efa6c6cdb55ecdef066eff7;p=gitmo%2FMoose.git does_role no-meta'ing --- diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index 42517ae..986dcab 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -121,11 +121,14 @@ sub calculate_all_roles { sub does_role { my ($self, $role_name) = @_; + (defined $role_name) || $self->throw_error("You must supply a role name to look for"); + foreach my $class ($self->class_precedence_list) { - next unless $class->can('meta') && $class->meta->can('roles'); - foreach my $role (@{$class->meta->roles}) { + my $meta = Class::MOP::class_of($class); + next unless $meta && $meta->can('roles'); + foreach my $role (@{$meta->roles}) { return 1 if $role->does_role($role_name); } }