use strict;
use warnings;
-use Data::OptList;
+use Data::OptList 0.107;
use Params::Util qw( _STRING );
use Sub::Exporter;
use Scalar::Util 'blessed';
Moose->throw_error("Must specify at least one role to apply to $applicant");
}
- my $roles = Data::OptList::mkopt( [@_] );
+ # If @_ contains role meta objects, mkopt will think that they're values,
+ # because they're references. In other words (roleobj1, roleobj2,
+ # roleobj3) will become [ [ roleobj1, roleobj2 ], [ roleobj3, undef ] ]
+ # -- this is no good. We'll preprocess @_ first to eliminate the potential
+ # bug.
+ # -- rjbs, 2011-04-08
+ my $roles = Data::OptList::mkopt( [@_], {
+ moniker => 'role',
+ name_test => sub {
+ ! ref $_[0] or blessed($_[0]) && $_[0]->isa('Moose::Meta::Role')
+ }
+ });
my @role_metas;
foreach my $role (@$roles) {
is( $foo->bar, $foo2, '... got the right value for bar now' );
}
+{
+ {
+ package MRole;
+ use Moose::Role;
+ sub meth { }
+ }
+
+ {
+ package MRole2;
+ use Moose::Role;
+ sub meth2 { }
+ }
+
+ {
+ use Moose::Meta::Class;
+ use Moose::Object;
+ use Moose::Util qw(apply_all_roles);
+
+ my $class = Moose::Meta::Class->create( 'Class' => (
+ superclasses => [ 'Moose::Object' ],
+ ));
+
+ apply_all_roles($class, MRole->meta, MRole2->meta);
+
+ ok(Class->can('meth'), "can meth");
+ ok(Class->can('meth2'), "can meth2");
+ }
+}
+
done_testing;