Skip to content

Commit

Permalink
Support { into => ... } and { into_level => ... } in unimport made by…
Browse files Browse the repository at this point in the history
… Moose::Exporter
  • Loading branch information
autarch committed Sep 11, 2016
1 parent 6e8e9c7 commit 6c50402
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ for, noteworthy changes.

{{$NEXT}}

[ENHANCEMENTS]

- The unimport sub generated by Moose::Exporter can now be called with
parameters like { into => 'Package' } or { into_level => 1 }, just like
the import sub it generates. Requested by Dmytro Zagashev. (RT #93666).

2.1805 2016-08-19

[BUG FIXES]
Expand Down
2 changes: 1 addition & 1 deletion lib/Moose/Exporter.pm
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ sub _make_unimport_sub {
my $meta_lookup = shift;

return sub {
my $caller = scalar caller();
my $caller = _get_caller(@_);
Moose::Exporter->_remove_keywords(
$caller,
[ keys %{$exports} ],
Expand Down
31 changes: 31 additions & 0 deletions t/metaclasses/moose_exporter.t
Original file line number Diff line number Diff line change
Expand Up @@ -674,4 +674,35 @@ use Test::Requires 'Test::Output'; # skip all if not installed

}

BEGIN {
{
package MooseX::ImportLevel;
use Moose ();

sub import {
Moose->import( { into_level => 1 } );
}

sub unimport {
Moose->unimport( { into_level => 1 } );
}
}

{
package ImportTest;

MooseX::ImportLevel->import;
::ok(
__PACKAGE__->can('has'),
'Moose->import( { into_level => 1 } ) exports helpers'
);

MooseX::ImportLevel->unimport;
::ok(
!__PACKAGE__->can('has'),
'Moose->unimport( { into_level => 1 } ) removes helpers'
);
}
}

done_testing;

0 comments on commit 6c50402

Please sign in to comment.