Make a combined role when we have >1 metaclass trait to apply
Dave Rolsky [Mon, 28 Jul 2008 12:45:54 +0000 (12:45 +0000)]
lib/Moose.pm

index 0322c7d..fed5941 100644 (file)
@@ -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() );
         }
     }