From: Dave Rolsky Date: Sat, 20 Sep 2008 14:30:29 +0000 (+0000) Subject: Be defensive against being called for a Moose::Meta::Role (which can X-Git-Tag: 0.58~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9eaf623d1f1b990d3dae67ad74c048c4b0da2915;p=gitmo%2FMoose.git Be defensive against being called for a Moose::Meta::Role (which can happen if we apply a trait to a role). --- diff --git a/lib/Moose/Util/MetaRole.pm b/lib/Moose/Util/MetaRole.pm index 2beb525..c15a990 100644 --- a/lib/Moose/Util/MetaRole.pm +++ b/lib/Moose/Util/MetaRole.pm @@ -12,11 +12,12 @@ sub apply_metaclass_roles { my $for = $options{for_class}; - my %old_classes = map { $_ => $for->meta->$_ } @Classes; + my %old_classes + = map { $_ => $for->meta->$_ } grep { $for->meta->can($_) } @Classes; my $meta = _make_new_metaclass( $for, \%options ); - for my $c (@Classes) { + for my $c ( grep { $meta->can($_) } @Classes ) { if ( $options{ $c . '_roles' } ) { my $class = _make_new_class( $meta->$c(),