X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoo%2F_Utils.pm;h=26670559249c2d30115263fb8c549c10b241d352;hb=108f8ddcc8c9c70cdc1eb4b60210e47a1dfe1d06;hp=e6a0420b654666262926a0255f84a5c3be6eb6cc;hpb=34a69e36826582e95f8a31215f6dff570b1bddc6;p=gitmo%2FMoo.git diff --git a/lib/Moo/_Utils.pm b/lib/Moo/_Utils.pm index e6a0420..2667055 100644 --- a/lib/Moo/_Utils.pm +++ b/lib/Moo/_Utils.pm @@ -16,7 +16,7 @@ use Moo::_mro; our @EXPORT = qw( _getglob _install_modifier _load_module _maybe_load_module _get_linear_isa _getstash _install_coderef _name_coderef - _in_global_destruction + _unimport_coderefs _in_global_destruction ); sub _in_global_destruction (); @@ -74,6 +74,21 @@ sub _name_coderef { can_haz_subname ? Sub::Name::subname(@_) : $_[1]; } +sub _unimport_coderefs { + my ($target, $info) = @_; + return unless $info and my $exports = $info->{exports}; + my %rev = reverse %$exports; + my $stash = _getstash($target); + foreach my $name (keys %$exports) { + if ($stash->{$name} and defined(&{$stash->{$name}})) { + if ($rev{$target->can($name)}) { + delete $stash->{$name}; + } + } + } +} + + sub STANDARD_DESTROY { my $self = shift;