Moose::Meta::Role's docs claim create() is "identical" to the create() in
Moose::Meta::Class, yet it currently does not honor "roles" if passed to it.
This commit fixes that by having Moose::Meta::Role::create() honor a roles
named parameter, and adds tests to validate/ensure that behaviour.
|| confess "You must pass a HASH ref of methods"
if exists $options{methods};
+ (ref $options{roles} eq 'ARRAY')
+ || $class->throw_error("You must pass an ARRAY ref of roles", data => $options{roles})
+ if exists $options{roles};
+
my $package = delete $options{package};
+ my $roles = delete $options{roles};
my $attributes = delete $options{attributes};
my $methods = delete $options{methods};
my $meta_name = exists $options{meta_name}
}
}
+ if ($roles) {
+ Moose::Util::apply_all_roles($meta, @$roles);
+ }
+
return $meta;
}
ok(!$role->is_anon_role, "the role is not anonymous");
+my $composed_role = Moose::Meta::Role->create(
+ 'MyItem::Role::Equipment2',
+ roles => [ $role ],
+);
+
+ok($composed_role->does_role('MyItem::Role::Equipment2'), "Role composed into role");
+
done_testing;