summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-06-08 14:13:31 -0500
committerJesse Luehrs <doy@tozt.net>2013-06-08 14:13:31 -0500
commit41f767bb6fa8f33b2f4ace0b909969dbcbbc37d5 (patch)
tree6696ba70c2574abd204b574aca57da96548f457f
parentb96eeb3ff1799f1f06dbd2cd9aad8bf9be81df89 (diff)
downloadreply-41f767bb6fa8f33b2f4ace0b909969dbcbbc37d5.tar.gz
reply-41f767bb6fa8f33b2f4ace0b909969dbcbbc37d5.zip
allow multiple independent lexical environments
-rw-r--r--lib/Reply/Plugin/Defaults.pm9
-rw-r--r--lib/Reply/Plugin/ResultCache.pm5
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/Reply/Plugin/Defaults.pm b/lib/Reply/Plugin/Defaults.pm
index b0c4e88..debed09 100644
--- a/lib/Reply/Plugin/Defaults.pm
+++ b/lib/Reply/Plugin/Defaults.pm
@@ -38,6 +38,15 @@ sub compile {
my $self = shift;
my ($next, $line, %args) = @_;
+ my @envs = (
+ ($args{environment} ? ($args{environment}) : ()),
+ values %{ $args{environments} },
+ );
+
+ if (@envs) {
+ $args{environment} = { map { %$_ } @envs }
+ }
+
return eval_closure(
source => "sub {\n$PREFIX;\n$line\n}",
terse_error => 1,
diff --git a/lib/Reply/Plugin/ResultCache.pm b/lib/Reply/Plugin/ResultCache.pm
index a973d05..91fda37 100644
--- a/lib/Reply/Plugin/ResultCache.pm
+++ b/lib/Reply/Plugin/ResultCache.pm
@@ -36,8 +36,9 @@ sub compile {
my $self = shift;
my ($next, $line, %args) = @_;
- $args{environment} ||= {};
- $args{environment}{'@' . $self->{result_name}} = $self->{results};
+ $args{environments}{''.__PACKAGE__} = {
+ "\@$self->{result_name}" => $self->{results},
+ };
$next->($line, %args);
}