From: Graham Knop Date: Fri, 13 Jun 2014 12:40:22 +0000 (-0400) Subject: plugin to persist package changes X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7c07a99a7d7e2f4ae02e45cd00771cf241590813;p=p5sagit%2FEval-WithLexicals.git plugin to persist package changes --- diff --git a/lib/Eval/WithLexicals/WithPackagePersistence.pm b/lib/Eval/WithLexicals/WithPackagePersistence.pm new file mode 100644 index 0000000..ced7ddb --- /dev/null +++ b/lib/Eval/WithLexicals/WithPackagePersistence.pm @@ -0,0 +1,32 @@ +package Eval::WithLexicals::WithPackagePersistence; +use Moo::Role; +use Sub::Quote; + +our $VERSION = '1.002000'; # 1.2.0 +$VERSION = eval $VERSION; + +around eval => sub { + my $orig = shift; + my($self) = @_; + + local *Eval::WithLexicals::Cage::package; + my @ret = $orig->(@_); + $self->in_package(Eval::WithLexicals::Cage::package()); + @ret; +}; + +around capture_code => sub { + my $orig = shift; + my($self) = @_; + + return ( + q{ + sub Eval::WithLexicals::Cage::package { + __PACKAGE__; + } + }, + $orig->(@_), + ) +}; + +1;