From: Dave Rolsky Date: Fri, 2 Oct 2009 02:04:37 +0000 (-0500) Subject: All methods which take a method name should not accept an empty string (using X-Git-Tag: 0.95~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f3ed8a15026e579291b5a8982930bc45d5e44126;p=gitmo%2FClass-MOP.git All methods which take a method name should not accept an empty string (using that makes Perl blow up in weird ways), but should allow false values. --- diff --git a/Changes b/Changes index c3ba5b9..e9afb67 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,12 @@ Revision history for Perl extension Class-MOP. + * Class::MOP::Class + * Class::MOP::Package + - Any method which takes a method name as an argument now allows names + which are false (like "0"), but the name must be defined and not be an + emptry string. + + 0.94 Tue, Sep 22, 2009 * Class::MOP::Attribute - Introduce set_raw_value and get_raw_value, side effect free variants diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 1eb958d..b953e36 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -596,7 +596,7 @@ sub class_precedence_list { sub add_before_method_modifier { my ($self, $method_name, $method_modifier) = @_; - (defined $method_name && $method_name) + (defined $method_name && length $method_name) || confess "You must pass in a method name"; my $method = $fetch_and_prepare_method->($self, $method_name); $method->add_before_modifier( @@ -606,7 +606,7 @@ sub class_precedence_list { sub add_after_method_modifier { my ($self, $method_name, $method_modifier) = @_; - (defined $method_name && $method_name) + (defined $method_name && length $method_name) || confess "You must pass in a method name"; my $method = $fetch_and_prepare_method->($self, $method_name); $method->add_after_modifier( @@ -616,7 +616,7 @@ sub class_precedence_list { sub add_around_method_modifier { my ($self, $method_name, $method_modifier) = @_; - (defined $method_name && $method_name) + (defined $method_name && length $method_name) || confess "You must pass in a method name"; my $method = $fetch_and_prepare_method->($self, $method_name); $method->add_around_modifier( @@ -640,7 +640,7 @@ sub class_precedence_list { sub find_method_by_name { my ($self, $method_name) = @_; - (defined $method_name && $method_name) + (defined $method_name && length $method_name) || confess "You must define a method name to find"; foreach my $class ($self->linearized_isa) { my $method = $self->initialize($class)->get_method($method_name); @@ -671,7 +671,7 @@ sub get_all_method_names { sub find_all_methods_by_name { my ($self, $method_name) = @_; - (defined $method_name && $method_name) + (defined $method_name && length $method_name) || confess "You must define a method name to find"; my @methods; foreach my $class ($self->linearized_isa) { @@ -688,7 +688,7 @@ sub find_all_methods_by_name { sub find_next_method_by_name { my ($self, $method_name) = @_; - (defined $method_name && $method_name) + (defined $method_name && length $method_name) || confess "You must define a method name to find"; my @cpl = $self->linearized_isa; shift @cpl; # discard ourselves diff --git a/lib/Class/MOP/Package.pm b/lib/Class/MOP/Package.pm index 3bfca1e..5ad509a 100644 --- a/lib/Class/MOP/Package.pm +++ b/lib/Class/MOP/Package.pm @@ -311,7 +311,7 @@ sub wrap_method_body { sub add_method { my ($self, $method_name, $method) = @_; - (defined $method_name && $method_name) + (defined $method_name && length $method_name) || confess "You must define a method name"; my $body; @@ -359,7 +359,7 @@ sub _code_is_mine { sub has_method { my ($self, $method_name) = @_; - defined($method_name) + (defined $method_name && length $method_name) || confess "You must define a method name"; return defined($self->get_method($method_name)); @@ -368,7 +368,7 @@ sub has_method { sub get_method { my ( $self, $method_name ) = @_; - defined($method_name) + (defined $method_name && length $method_name) || confess "You must define a method name"; my $method_map = $self->_method_map; @@ -404,7 +404,7 @@ sub get_method { sub remove_method { my ($self, $method_name) = @_; - (defined $method_name && $method_name) + (defined $method_name && length $method_name) || confess "You must define a method name"; my $removed_method = delete $self->_full_method_map->{$method_name};