From: Shawn M Moore Date: Sun, 9 Nov 2008 03:47:34 +0000 (+0000) Subject: Factor out wrapper creation so users can give a prototype to the wrappers with a... X-Git-Tag: 0.62~33 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b4f00a3495207ae3a6018e02c82ab8aa3b9c2bfc;p=gitmo%2FMoose.git Factor out wrapper creation so users can give a prototype to the wrappers with a little less pain --- diff --git a/lib/Moose/Exporter.pm b/lib/Moose/Exporter.pm index ec8dd28..b4cf84a 100644 --- a/lib/Moose/Exporter.pm +++ b/lib/Moose/Exporter.pm @@ -168,7 +168,7 @@ sub _make_sub_exporter_params { our $CALLER; sub _make_wrapped_sub { - shift; + my $self = shift; my $fq_name = shift; my $sub = shift; my $export_recorder = shift; @@ -182,8 +182,9 @@ sub _make_wrapped_sub { return sub { my $caller = $CALLER; - my $sub - = Class::MOP::subname( $fq_name => sub { $sub->( $caller, @_ ) } ); + my $wrapper = $self->_make_wrapper($caller, $sub, $fq_name); + + my $sub = Class::MOP::subname($fq_name => $wrapper); $export_recorder->{$sub} = 1; @@ -191,6 +192,15 @@ sub _make_wrapped_sub { }; } +sub _make_wrapper { + shift; + my $caller = shift; + my $sub = shift; + my $fq_name = shift; + + return sub { $sub->($caller, @_) }; +} + sub _make_import_sub { shift; my $exporting_package = shift;