From: gfx Date: Sun, 20 Sep 2009 07:34:00 +0000 (+0900) Subject: Add has_x_method_modifiers, but not yet tested X-Git-Tag: 0.32~42 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3370794fc5ea58f40c7e4f7f89c4f4960e28f9d7;p=gitmo%2FMouse.git Add has_x_method_modifiers, but not yet tested --- diff --git a/lib/Mouse/Meta/Role.pm b/lib/Mouse/Meta/Role.pm index 403b781..35bc9ea 100644 --- a/lib/Mouse/Meta/Role.pm +++ b/lib/Mouse/Meta/Role.pm @@ -222,6 +222,11 @@ for my $modifier_type (qw/before after around override/) { push @{ $self->{$modifier}->{$method_name} ||= [] }, $method; return; }; + my $has_method_modifiers = sub{ + my($self, $method_name) = @_; + my $m = $self->{$modifier}->{$method_name}; + return $m && @{$m} != 0; + }; my $get_method_modifiers = sub { my ($self, $method_name) = @_; return @{ $self->{$modifier}->{$method_name} ||= [] } @@ -229,6 +234,7 @@ for my $modifier_type (qw/before after around override/) { no strict 'refs'; *{ 'add_' . $modifier_type . '_method_modifier' } = $add_method_modifier; + *{ 'has_' . $modifier_type . '_method_modifiers' } = $has_method_modifiers; *{ 'get_' . $modifier_type . '_method_modifiers' } = $get_method_modifiers; } diff --git a/lib/Mouse/Object.pm b/lib/Mouse/Object.pm index 8871a19..47626d3 100644 --- a/lib/Mouse/Object.pm +++ b/lib/Mouse/Object.pm @@ -137,13 +137,7 @@ sub does { (defined $role_name) || confess "You must supply a role name to does()"; - my $meta = $self->meta; - foreach my $class ($meta->linearized_isa) { - my $m = ref($meta)->initialize($class); - return 1 - if $m->can('does_role') && $m->does_role($role_name); - } - return 0; + return $self->meta->does_role($role_name); }; 1;