[Moose-commits] r7667 - in Moose/trunk: lib/Moose/Util
t/050_metaclasses
rafl at code2.0beta.co.uk
rafl at code2.0beta.co.uk
Sat Feb 14 01:10:05 GMT 2009
Author: rafl
Date: 2009-02-13 17:10:05 -0800 (Fri, 13 Feb 2009)
New Revision: 7667
Modified:
Moose/trunk/lib/Moose/Util/MetaRole.pm
Moose/trunk/t/050_metaclasses/015_metarole.t
Log:
Allow Moose::Util::MetaRole to apply roles to wrapped_method_metaclass.
Modified: Moose/trunk/lib/Moose/Util/MetaRole.pm
===================================================================
--- Moose/trunk/lib/Moose/Util/MetaRole.pm 2009-02-14 00:44:55 UTC (rev 7666)
+++ Moose/trunk/lib/Moose/Util/MetaRole.pm 2009-02-14 01:10:05 UTC (rev 7667)
@@ -48,6 +48,7 @@
metaclass
attribute_metaclass
method_metaclass
+ wrapped_method_metaclass
instance_metaclass
);
@@ -64,6 +65,7 @@
qw(
attribute_metaclass
method_metaclass
+ wrapped_method_metaclass
instance_metaclass
);
@@ -199,6 +201,8 @@
=item * method_metaclass_roles => \@roles
+=item * wrapped_method_metaclass_roles => \@roles
+
=item * instance_metaclass_roles => \@roles
=item * constructor_class_roles => \@roles
Modified: Moose/trunk/t/050_metaclasses/015_metarole.t
===================================================================
--- Moose/trunk/t/050_metaclasses/015_metarole.t 2009-02-14 00:44:55 UTC (rev 7666)
+++ Moose/trunk/t/050_metaclasses/015_metarole.t 2009-02-14 01:10:05 UTC (rev 7667)
@@ -5,7 +5,7 @@
use lib 't/lib', 'lib';
-use Test::More tests => 73;
+use Test::More tests => 78;
use Test::Exception;
use Moose::Util::MetaRole;
@@ -77,6 +77,26 @@
{
Moose::Util::MetaRole::apply_metaclass_roles(
+ for_class => 'My::Class',
+ wrapped_method_metaclass_roles => ['Role::Foo'],
+ );
+
+ ok( My::Class->meta()->wrapped_method_metaclass()->meta()->does_role('Role::Foo'),
+ q{apply Role::Foo to My::Class->meta()'s wrapped method metaclass} );
+ ok( My::Class->meta()->method_metaclass()->meta()->does_role('Role::Foo'),
+ '... My::Class->meta() still does Role::Foo' );
+ ok( My::Class->meta()->meta()->does_role('Role::Foo'),
+ '... My::Class->meta() still does Role::Foo' );
+ ok( My::Class->meta()->attribute_metaclass()->meta()->does_role('Role::Foo'),
+ q{... My::Class->meta()'s attribute metaclass still does Role::Foo} );
+
+ My::Class->meta()->add_after_method_modifier( 'bar' => sub { 'bar' } );
+ is( My::Class->meta()->get_method('bar')->foo(), 10,
+ '... call foo() on a wrapped method metaclass object' );
+}
+
+{
+ Moose::Util::MetaRole::apply_metaclass_roles(
for_class => 'My::Class',
instance_metaclass_roles => ['Role::Foo'],
);
More information about the Moose-commits
mailing list