From: Florian Ragwitz Date: Fri, 7 Aug 2009 19:25:21 +0000 (+0200) Subject: Allow attributes to be have a name which is false. X-Git-Tag: 0.92~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d93304881688b2cb97c053de2e30dd169d49507d;p=gitmo%2FClass-MOP.git Allow attributes to be have a name which is false. --- diff --git a/lib/Class/MOP/Attribute.pm b/lib/Class/MOP/Attribute.pm index 582d7fd..8426d9c 100644 --- a/lib/Class/MOP/Attribute.pm +++ b/lib/Class/MOP/Attribute.pm @@ -32,7 +32,7 @@ sub new { my $name = $options{name}; - (defined $name && $name) + (defined $name) || confess "You must provide a name for the attribute"; $options{init_arg} = $name diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 400ddd3..6f1dd31 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -854,14 +854,14 @@ sub invalidate_meta_instance { sub has_attribute { my ($self, $attribute_name) = @_; - (defined $attribute_name && $attribute_name) + (defined $attribute_name) || confess "You must define an attribute name"; exists $self->get_attribute_map->{$attribute_name}; } sub get_attribute { my ($self, $attribute_name) = @_; - (defined $attribute_name && $attribute_name) + (defined $attribute_name) || confess "You must define an attribute name"; return $self->get_attribute_map->{$attribute_name} # NOTE: @@ -872,7 +872,7 @@ sub get_attribute { sub remove_attribute { my ($self, $attribute_name) = @_; - (defined $attribute_name && $attribute_name) + (defined $attribute_name) || confess "You must define an attribute name"; my $removed_attribute = $self->get_attribute_map->{$attribute_name}; return unless defined $removed_attribute;