No need for arrayref with single argument to also
[gitmo/Moose.git] / lib / Moose / Role.pm
index 4c6ae21..4d2bd67 100644 (file)
@@ -106,7 +106,7 @@ sub augment {
     croak "Moose::Role cannot support 'augment'";
 }
 
-my $exporter = Moose::Exporter->build_import_methods(
+my $exporter = Moose::Exporter->setup_import_methods(
     with_caller => [
         qw( with requires excludes has before after around override make_immutable )
     ],
@@ -115,14 +115,18 @@ my $exporter = Moose::Exporter->build_import_methods(
         \&Carp::confess,
         \&Scalar::Util::blessed,
     ],
-    also => sub { init_meta(shift) },
 );
 
 {
     my %METAS;
 
     sub init_meta {
-        my $role = shift;
+        shift;
+        my %args = @_;
+
+        my $role = $args{for_class}
+            or confess
+            "Cannot call init_meta without specifying a for_class";
 
         return $METAS{$role} if exists $METAS{$role};
 
@@ -217,6 +221,15 @@ Moose::Role offers a way to remove the keywords it exports, through the
 C<unimport> method. You simply have to say C<no Moose::Role> at the bottom of
 your code for this to work.
 
+=head2 B<< Moose::Role->init_meta(for_class => $role, metaclass => $metaclass) >>
+
+The C<init_meta> method sets up the metaclass object for the role
+specified by C<for_class>. It also injects a a C<meta> accessor into
+the role so you can get at this object.
+
+The default metaclass is L<Moose::Meta::Role>. You can specify an
+alternate metaclass with the C<metaclass> parameter.
+
 =head1 CAVEATS
 
 Role support has only a few caveats: