From: Shawn M Moore Date: Thu, 14 Jun 2012 20:01:26 +0000 (-0500) Subject: If you pass no roles, just instantiate the superclass. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=03d53c1c11c0fb0870dae6248fc60b6a4a89b1ea;p=gitmo%2FMoose.git If you pass no roles, just instantiate the superclass. I feel like I want MooseX::ClassCompositor here. --- diff --git a/lib/Moose/Util.pm b/lib/Moose/Util.pm index 28ec30f..5e0e99d 100644 --- a/lib/Moose/Util.pm +++ b/lib/Moose/Util.pm @@ -480,13 +480,20 @@ sub throw { %args = @_; } - my $superclasses = delete($args{superclasses}) || ['Throwable::Error']; + my $superclass = delete($args{superclass}) || 'Throwable::Error'; my $roles = delete($args{roles}); - my $metaclass = Moose::Meta::Class->create_anon_class( - superclasses => $superclasses, - ($roles ? (roles => $roles) : ()), - ); + my $metaclass; + + if ($roles) { + $metaclass = Moose::Meta::Class->create_anon_class( + superclasses => [$superclass], + roles => $roles, + ); + } + else { + $metaclass = Moose::Meta::Class->initialize($superclass); + } $metaclass->name->throw(\%args); }