From: Shawn M Moore Date: Mon, 22 Dec 2008 04:06:32 +0000 (+0000) Subject: Same API as Moose for Mouse::Meta::Attribute->new X-Git-Tag: 0.19~80 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2608b11522c42ce940bcc72743cdee5bb9d0c120;p=gitmo%2FMouse.git Same API as Moose for Mouse::Meta::Attribute->new --- diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index f076668..ab72881 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -7,17 +7,16 @@ use Carp 'confess'; use Scalar::Util (); sub new { - my $class = shift; - my %args = @_; + my ($class, $name, %options) = @_; - my $name = $args{name}; + $options{name} = $name; - $args{init_arg} = $name - unless exists $args{init_arg}; + $options{init_arg} = $name + unless exists $options{init_arg}; - $args{is} ||= ''; + $options{is} ||= ''; - bless \%args, $class; + bless \%options, $class; } sub name { $_[0]->{name} } @@ -232,7 +231,7 @@ sub create { $args{find_type_constraint} = $code; } - my $attribute = $self->new(%args); + my $attribute = $self->new($name, %args); $attribute->_create_args(\%args); diff --git a/t/800_shikabased/008-create_class.t b/t/800_shikabased/008-create_class.t index 6d6bad5..1566d90 100644 --- a/t/800_shikabased/008-create_class.t +++ b/t/800_shikabased/008-create_class.t @@ -42,7 +42,10 @@ isa_ok( superclasses => [ "FooBar", "Mouse::Object" ], attributes => [ Mouse::Meta::Attribute->new( - name => "foo", is => "rw", default => "yay" + "foo" => ( + is => "rw", + default => "yay", + ), ) ], methods => {