X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FDevel-REPL.git;a=blobdiff_plain;f=lib%2FDevel%2FREPL%2FPlugin%2FCommands.pm;h=953009c8dad7a0b631c77e2eb6d79bb48b31d30d;hp=1b43106ab53b280934d43b78b7eff9e252a0b1a0;hb=bd67131f89dd3b141458a20e3b456f23d6f62ee0;hpb=4d33251a9f6d375aaafd8aa274743c68dec8f720 diff --git a/lib/Devel/REPL/Plugin/Commands.pm b/lib/Devel/REPL/Plugin/Commands.pm index 1b43106..953009c 100644 --- a/lib/Devel/REPL/Plugin/Commands.pm +++ b/lib/Devel/REPL/Plugin/Commands.pm @@ -26,18 +26,24 @@ sub AFTER_PLUGIN { after 'setup_commands' => sub { my ($self) = @_; weaken($self); - $self->command_set->{load_plugin} = sub { $self->load_plugin(@_); }; + $self->command_set->{load_plugin} = sub { + my $self = shift; + sub { $self->load_plugin(@_); }; + }; }; sub command_installer { my ($self) = @_; - my %command_set = %{$self->command_set}; + my $command_set = $self->command_set; + my %command_subs = map { + ($_ => $command_set->{$_}->($self)); + } keys %$command_set; return sub { my $package = shift; - foreach my $command (keys %command_set) { + foreach my $command (keys %command_subs) { no strict 'refs'; no warnings 'redefine'; - *{"${package}::${command}"} = $command_set{$command}; + *{"${package}::${command}"} = $command_subs{$command}; } }; }