- Users can now select a different metaclass with the "-metaclass"
option to import, for classes and roles (Sartak)
+ * Moose::Meta::Role
+ - Make method_metaclass an attr so can accept a metarole application.
+ (jdv)
+
0.74 Tue, April 7, 2009
* Moose::Meta::Role
* Moose::Meta::Method::Destructor
}) if exists $methods->{remove};
}
+$META->add_attribute(
+ 'method_metaclass',
+ reader => 'method_metaclass',
+ default => 'Moose::Meta::Role::Method',
+);
+
## some things don't always fit, so they go here ...
sub add_attribute {
## ------------------------------------------------------------------
## methods
-sub method_metaclass { 'Moose::Meta::Role::Method' }
-
sub get_method_map {
my $self = shift;
use lib 't/lib', 'lib';
-use Test::More tests => 78;
+use Test::More tests => 80;
use Test::Exception;
use Moose::Util::MetaRole;
ExportsMoose->import;
} 'import module which loads a role from disk during init_meta';
+{
+ package Foo::Meta::Role;
+
+ use Moose::Role;
+}
+{
+ package Foo::Role;
+
+ Moose::Exporter->setup_import_methods(
+ also => 'Moose::Role',
+ );
+
+ sub init_meta {
+ shift;
+ my %p = @_;
+ Moose::Role->init_meta(%p);
+ return Moose::Util::MetaRole::apply_metaclass_roles(
+ for_class => $p{for_class},
+ method_metaclass_roles => [ 'Foo::Meta::Role', ],
+ );
+ }
+}
+{
+ package Role::Baz;
+
+ Foo::Role->import;
+
+ sub bla {}
+}
+{
+ package My::Class12;
+
+ use Moose;
+
+ with( 'Role::Baz' );
+}
+{
+ ok(
+ My::Class12->meta->does_role( 'Role::Baz' ),
+ 'role applied'
+ );
+ my $method = My::Class12->meta->get_method( 'bla' );
+ ok(
+ $method->meta->does_role( 'Foo::Meta::Role' ),
+ 'method_metaclass_role applied'
+ );
+}