fix RT#44429 after discussion on the mailing list
[gitmo/Moose.git] / lib / Moose / Exporter.pm
index 3a35c4c..b998614 100644 (file)
@@ -3,7 +3,7 @@ package Moose::Exporter;
 use strict;
 use warnings;
 
-our $VERSION   = '0.72';
+our $VERSION   = '0.73';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
@@ -193,12 +193,18 @@ sub _make_wrapped_sub {
 }
 
 sub _make_wrapper {
-    shift;
+    my $class   = shift;
     my $caller  = shift;
     my $sub     = shift;
     my $fq_name = shift;
 
-    return sub { $sub->($caller, @_) };
+    my $wrapper = sub { $sub->($caller, @_) };
+    if (my $proto = prototype $sub) {
+        # XXX - Perl's prototype sucks. Use & to make set_prototype
+        # ignore the fact that we're passing a "provate variable"
+        &Scalar::Util::set_prototype($wrapper, $proto);
+    }
+    return $wrapper;
 }
 
 sub _make_import_sub {
@@ -292,7 +298,7 @@ sub _apply_meta_traits {
 
     return unless @{$traits};
 
-    my $meta = $class->meta();
+    my $meta = Class::MOP::class_of($class);
 
     my $type = ( split /::/, ref $meta )[-1]
         or Moose->throw_error(
@@ -422,7 +428,9 @@ C<MooseX> module, as long as they all use C<Moose::Exporter>.
 
 This module provides two public methods:
 
-=head2 Moose::Exporter->setup_import_methods(...)
+=over 4
+
+=item  B<< Moose::Exporter->setup_import_methods(...) >>
 
 When you call this method, C<Moose::Exporter> build custom C<import>
 and C<unimport> methods for your module. The import method will export
@@ -434,7 +442,7 @@ exported functions.
 
 This method accepts the following parameters:
 
-=over 4
+=over 8
 
 =item * with_caller => [ ... ]
 
@@ -469,12 +477,14 @@ when C<unimport> is called.
 
 =back
 
-=head2 Moose::Exporter->build_import_methods(...)
+=item B<< Moose::Exporter->build_import_methods(...) >>
 
 Returns two code refs, one for import and one for unimport.
 
 Used by C<setup_import_methods>.
 
+=back
+
 =head1 IMPORTING AND init_meta
 
 If you want to set an alternative base object class or metaclass