From: Stevan Little Date: Tue, 5 Feb 2008 19:45:31 +0000 (+0000) Subject: making has $name => {} fail X-Git-Tag: 0_37~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a28fe77b37f4fd3df2ff3e97f8309b5022177f4f;p=gitmo%2FMoose.git making has $name => {} fail --- diff --git a/Changes b/Changes index 9b2ff91..9570b53 100644 --- a/Changes +++ b/Changes @@ -5,6 +5,8 @@ Revision history for Perl extension Moose - fixed some details in Moose::init_meta and its superclass handling (thanks thepler) - added tests for this (thanks thepler) + - 'has' now dies if you don't pass in name + value pairs * Moose::Meta::Class Moose::Meta::Method::Constructor diff --git a/lib/Moose.pm b/lib/Moose.pm index 8b7a166..e5c8a28 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -100,7 +100,9 @@ use Moose::Util (); has => sub { my $class = $CALLER; return subname 'Moose::has' => sub ($;%) { - my ( $name, %options ) = @_; + my $name = shift; + die 'Usage: has \'name\' => ( key => value, ... )' if @_ == 1; + my %options = @_; my $attrs = ( ref($name) eq 'ARRAY' ) ? $name : [ ($name) ]; $class->meta->add_attribute( $_, %options ) for @$attrs; };