has => sub {
my $meta = _find_meta();
return Class::MOP::subname('Moose::Role::has' => sub ($;%) {
- my ($name, %options) = @_;
- $meta->add_attribute($name, %options)
+ my $name = shift;
+ confess 'Usage: has \'name\' => ( key => value, ... )' if @_ == 1;
+ my %options = @_;
+ my $attrs = ( ref($name) eq 'ARRAY' ) ? $name : [ ($name) ];
+ $meta->add_attribute( $_, %options ) for @$attrs;
});
},
before => sub {
use strict;
use warnings;
-use Test::More tests => 42;
+use Test::More tests => 44;
use Test::Exception;
BEGIN {
{
{
+ package Test::Arrayref::RoleAttributes::Role;
+ use Moose::Role;
+
+ has [qw(foo bar baz)] => (
+ is => 'rw',
+ );
+
+ }
+ {
+ package Test::Arrayref::RoleAttributes;
+ use Moose;
+ with 'Test::Arrayref::RoleAttributes::Role';
+ }
+
+ my $test = Test::Arrayref::RoleAttributes->new;
+ isa_ok($test, 'Test::Arrayref::RoleAttributes');
+ can_ok($test, qw(foo bar baz));
+
+}
+
+{
+ {
package Test::UndefDefault::Attributes;
use Moose;