From: Shawn M Moore Date: Wed, 16 Jul 2008 05:44:20 +0000 (+0000) Subject: We need Attribute->validate_args to take a hashref instead of a hash X-Git-Tag: 0.19~257 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=commitdiff_plain;h=1bbaa8edd19af95a395eb59d34602c1b85def6d6;hp=ca7941e5f5a56ef4e0c61835538c505645152085 We need Attribute->validate_args to take a hashref instead of a hash --- diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index 011ff4e..050ec49 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -168,7 +168,7 @@ sub create { $args{class} = $class; %args = $self->canonicalize_args($name, %args); - $self->validate_args($name, %args); + $self->validate_args($name, \%args); $args{type_constraint} = delete $args{isa} if exists $args{isa}; @@ -234,25 +234,27 @@ sub canonicalize_args { sub validate_args { my $self = shift; my $name = shift; - my %args = @_; + my $args = shift; confess "You can not use lazy_build and default for the same attribute ($name)" - if $args{lazy_build} && exists $args{default}; + if $args->{lazy_build} && exists $args->{default}; confess "You cannot have lazy attribute ($name) without specifying a default value for it" - if $args{lazy} && !exists($args{default}) && !exists($args{builder}); + if $args->{lazy} + && !exists($args->{default}) + && !exists($args->{builder}); confess "References are not allowed as default values, you must wrap the default of '$name' in a CODE reference (ex: sub { [] } and not [])" - if ref($args{default}) - && ref($args{default}) ne 'CODE'; + if ref($args->{default}) + && ref($args->{default}) ne 'CODE'; confess "You cannot auto-dereference without specifying a type constraint on attribute $name" - if $args{auto_deref} && !exists($args{isa}); + if $args->{auto_deref} && !exists($args->{isa}); confess "You cannot auto-dereference anything other than a ArrayRef or HashRef on attribute $name" - if $args{auto_deref} - && $args{isa} ne 'ArrayRef' - && $args{isa} ne 'HashRef'; + if $args->{auto_deref} + && $args->{isa} ne 'ArrayRef' + && $args->{isa} ne 'HashRef'; confess "Trigger must be a CODE or HASH ref on attribute ($name)" if $args{trigger} @@ -422,7 +424,7 @@ on success, otherwise Ces. Canonicalizes some arguments to create. In particular, C is canonicalized into C, C, etc. -=head2 validate_args Name, %args -> 1 | ERROR +=head2 validate_args Name, \%args -> 1 | ERROR Checks that the arguments to create the attribute (ie those specified by C) are valid.