From: gfx Date: Fri, 26 Feb 2010 06:39:11 +0000 (+0900) Subject: Make roles smarter X-Git-Tag: 0.50_04~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=467c4815ec15a74e6aa4970b6d69bcb4a6fa0b7f;p=gitmo%2FMouse.git Make roles smarter --- diff --git a/lib/Mouse/Meta/Role.pm b/lib/Mouse/Meta/Role.pm index e1f3f71..a41d5a6 100644 --- a/lib/Mouse/Meta/Role.pm +++ b/lib/Mouse/Meta/Role.pm @@ -149,13 +149,13 @@ sub _apply_modifiers{ } for my $modifier_type (qw/before around after/) { - my $modifiers = $role->{"${modifier_type}_method_modifiers"} + my $table = $role->{"${modifier_type}_method_modifiers"} or next; my $add_modifier = "add_${modifier_type}_method_modifier"; - foreach my $method_name (keys %{$modifiers}){ - foreach my $code(@{ $modifiers->{$method_name} }){ + while(my($method_name, $modifiers) = each %{$table}){ + foreach my $code(@{ $modifiers }){ next if $consumer->{"_applied_$modifier_type"}{$method_name, $code}++; # skip applied modifiers $consumer->$add_modifier($method_name => $code); } @@ -167,7 +167,7 @@ sub _apply_modifiers{ sub _append_roles{ my($role, $consumer, $args) = @_; - my $roles = ($args->{_to} eq 'role') ? $consumer->get_roles : $consumer->roles; + my $roles = $consumer->{roles}; foreach my $r($role, @{$role->get_roles}){ if(!$consumer->does_role($r->name)){