method_metaclass
wrapped_method_metaclass
instance_metaclass
+ application_to_class_class
+ application_to_role_class
+ application_to_instance_class
);
my $old_meta = Class::MOP::class_of($for);
method_metaclass
wrapped_method_metaclass
instance_metaclass
+ application_to_class_class
+ application_to_role_class
+ application_to_instance_class
);
return $new_metaclass->reinitialize( $for, %classes );
=item * destructor_class_roles => \@roles
+=item * application_to_class_class_roles => \@roles
+
+=item * application_to_role_class_roles => \@roles
+
+=item * application_to_instance_class_roles => \@roles
+
These parameter all specify one or more roles to be applied to the
specified metaclass. You can pass any or all of these parameters at
once.
use lib 't/lib', 'lib';
-use Test::More tests => 80;
+use Test::More tests => 89;
use Test::Exception;
use Moose::Util::MetaRole;
}
{
+ package My::Role;
+ use Moose::Role;
+}
+
+{
Moose::Util::MetaRole::apply_metaclass_roles(
for_class => 'My::Class',
metaclass_roles => ['Role::Foo'],
}
{
+ Moose::Util::MetaRole::apply_metaclass_roles(
+ for_class => 'My::Role',
+ application_to_class_class_roles => ['Role::Foo'],
+ );
+
+ ok( My::Role->meta->application_to_class_class->meta->does_role('Role::Foo'),
+ q{apply Role::Foo to My::Role->meta's application_to_class class} );
+
+ is( My::Role->meta->application_to_class_class->new->foo, 10,
+ q{... call foo() on an application_to_class instance} );
+}
+
+{
+ Moose::Util::MetaRole::apply_metaclass_roles(
+ for_class => 'My::Role',
+ application_to_role_class_roles => ['Role::Foo'],
+ );
+
+ ok( My::Role->meta->application_to_role_class->meta->does_role('Role::Foo'),
+ q{apply Role::Foo to My::Role->meta's application_to_role class} );
+ ok( My::Role->meta->application_to_class_class->meta->does_role('Role::Foo'),
+ q{... My::Role->meta's application_to_class class still does Role::Foo} );
+
+ is( My::Role->meta->application_to_role_class->new->foo, 10,
+ q{... call foo() on an application_to_role instance} );
+}
+
+{
+ Moose::Util::MetaRole::apply_metaclass_roles(
+ for_class => 'My::Role',
+ application_to_instance_class_roles => ['Role::Foo'],
+ );
+
+ ok( My::Role->meta->application_to_instance_class->meta->does_role('Role::Foo'),
+ q{apply Role::Foo to My::Role->meta's application_to_instance class} );
+ ok( My::Role->meta->application_to_role_class->meta->does_role('Role::Foo'),
+ q{... My::Role->meta's application_to_role class still does Role::Foo} );
+ ok( My::Role->meta->application_to_class_class->meta->does_role('Role::Foo'),
+ q{... My::Role->meta's application_to_class class still does Role::Foo} );
+
+ is( My::Role->meta->application_to_instance_class->new->foo, 10,
+ q{... call foo() on an application_to_instance instance} );
+}
+
+{
Moose::Util::MetaRole::apply_base_class_roles(
for_class => 'My::Class',
roles => ['Role::Foo'],