From: Yuval Kogman Date: Fri, 14 Jul 2006 02:09:03 +0000 (+0000) Subject: find_method_by_name in Moose::Meta::Role, + bug fix for composition over inherited... X-Git-Tag: 0_12~18^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=be4427d0fd6e97cec7dad07afa95fa450bca59f7;p=gitmo%2FMoose.git find_method_by_name in Moose::Meta::Role, + bug fix for composition over inherited methods --- diff --git a/lib/Moose/Meta/Role.pm b/lib/Moose/Meta/Role.pm index 4e202d0..7082f7b 100644 --- a/lib/Moose/Meta/Role.pm +++ b/lib/Moose/Meta/Role.pm @@ -150,9 +150,10 @@ sub _clean_up_required_methods { sub name { (shift)->_role_meta->name } sub version { (shift)->_role_meta->version } -sub get_method { (shift)->_role_meta->get_method(@_) } -sub has_method { (shift)->_role_meta->has_method(@_) } -sub alias_method { (shift)->_role_meta->alias_method(@_) } +sub get_method { (shift)->_role_meta->get_method(@_) } +sub find_method_by_name { (shift)->_role_meta->find_method_by_name(@_) } +sub has_method { (shift)->_role_meta->has_method(@_) } +sub alias_method { (shift)->_role_meta->alias_method(@_) } sub get_method_list { my ($self) = @_; grep { @@ -234,10 +235,7 @@ sub _check_required_methods { # the require methods stuff. foreach my $required_method_name ($self->get_required_method_list) { - # FIXME: - # This should not call has_method, instead it should - # call find_method_by_name (to be added to Class::MOP) - unless ($other->has_method($required_method_name)) { + unless ($other->find_method_by_name($required_method_name)) { if ($other->isa('Moose::Meta::Role')) { $other->add_required_methods($required_method_name); } @@ -246,30 +244,6 @@ sub _check_required_methods { "to be implemented by '" . $other->name . "'"; } } - else { - # NOTE: - # we need to make sure that the method is - # not a method modifier, because those do - # not satisfy the requirements ... - - # FIXME: - # This should also call find_method_by_name - my $method = $other->get_method($required_method_name); - # check if it is an override or a generated accessor .. - (!$method->isa('Moose::Meta::Method::Overriden') && - !$method->isa('Class::MOP::Attribute::Accessor')) - || confess "'" . $self->name . "' requires the method '$required_method_name' " . - "to be implemented by '" . $other->name . "', the method is only a method modifier"; - # before/after/around methods are a little trickier - # since we wrap the original local method (if applicable) - # so we need to check if the original wrapped method is - # from the same package, and not a wrap of the super method - if ($method->isa('Class::MOP::Method::Wrapped')) { - ($method->get_original_method->package_name eq $other->name) - || confess "'" . $self->name . "' requires the method '$required_method_name' " . - "to be implemented by '" . $other->name . "', the method is only a method modifier"; - } - } } } @@ -445,6 +419,8 @@ probably not that much really). =over 4 +=item B + =item B =item B