From: gfx Date: Sun, 20 Dec 2009 07:08:15 +0000 (+0900) Subject: Tweaks X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8d5d82c25c1cbf20e16b3680aa79aa22a7d6178e;p=gitmo%2FMouse.git Tweaks --- diff --git a/lib/Mouse/Util.pm b/lib/Mouse/Util.pm index ddad56d..1273420 100644 --- a/lib/Mouse/Util.pm +++ b/lib/Mouse/Util.pm @@ -173,12 +173,14 @@ BEGIN { sub resolve_metaclass_alias { my ( $type, $metaclass_name, %options ) = @_; - my $cache_key = $type . q{ } . ( $options{trait} ? '-Trait' : '' ); + my @trait = $options{trait} ? ('Trait') : (); + my $cache_key = join '-', + $type, @trait, $metaclass_name; - return $cache{$cache_key}{$metaclass_name} ||= do{ + return $cache{$cache_key} ||= do{ my $possible_full_name = join '::', - 'Mouse::Meta', $type, 'Custom', ($options{trait} ? 'Trait' : ()), $metaclass_name + 'Mouse::Meta', $type, 'Custom', @trait, $metaclass_name ; my $loaded_class = load_first_existing_class( @@ -280,12 +282,13 @@ sub apply_all_roles { # Basis of Data::OptList my $max = scalar(@_); for (my $i = 0; $i < $max ; $i++) { + my $role_name = $_[$i]; + if ($i + 1 < $max && ref($_[$i + 1])) { - push @roles, [ $_[$i] => $_[++$i] ]; + push @roles, [ $role_name=> $_[++$i] ]; } else { - push @roles, [ $_[$i] => undef ]; + push @roles, [ $role_name => undef ]; } - my $role_name = $roles[-1][0]; load_class($role_name); is_a_metarole( get_metaclass_by_name($role_name) )