From: Dave Rolsky Date: Mon, 28 Jul 2008 12:45:54 +0000 (+0000) Subject: Make a combined role when we have >1 metaclass trait to apply X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bd0339f4bdcccf0ff8e071876584b7668e7d5fb7;p=gitmo%2FMoose.git Make a combined role when we have >1 metaclass trait to apply --- diff --git a/lib/Moose.pm b/lib/Moose.pm index 0322c7d..fed5941 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -218,10 +218,13 @@ use Moose::Util (); my ( $class, $traits ) = @_; return - unless $traits && @{ $traits }; + unless $traits && @$traits; - for my $trait ( @{ $traits } ) { - $trait->meta()->apply_to_metaclass_instance( $class->meta() ); + if ( @$traits == 1 ) { + $traits->[0]->meta()->apply_to_metaclass_instance( $class->meta() ); + } else { + Moose::Meta::Role->combine(@$traits) + ->apply_to_metaclass_instance( $class->meta() ); } }