diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-05-31 04:51:29 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-05-31 04:51:29 -0500 |
commit | 84640f1b3b402d2a64a5005d757f7171df2d658d (patch) | |
tree | 4c916aeffe0cecc9049400592a809f6e2b697135 /lib/Reply/Plugin/ResultCache.pm | |
parent | cf4edf5661ed8cfaa392e5ee63b0d75a70ac0c87 (diff) | |
download | reply-84640f1b3b402d2a64a5005d757f7171df2d658d.tar.gz reply-84640f1b3b402d2a64a5005d757f7171df2d658d.zip |
add some configuration to a couple plugins
Diffstat (limited to 'lib/Reply/Plugin/ResultCache.pm')
-rw-r--r-- | lib/Reply/Plugin/ResultCache.pm | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Reply/Plugin/ResultCache.pm b/lib/Reply/Plugin/ResultCache.pm index b43eff3..2a11a02 100644 --- a/lib/Reply/Plugin/ResultCache.pm +++ b/lib/Reply/Plugin/ResultCache.pm @@ -6,9 +6,11 @@ use base 'Reply::Plugin'; sub new { my $class = shift; + my %opts = @_; my $self = $class->SUPER::new(@_); $self->{results} = []; + $self->{result_name} = $opts{variable} || 'res'; return $self; } @@ -18,7 +20,7 @@ sub compile { my ($next, $line, %args) = @_; $args{environment} ||= {}; - $args{environment}{'@res'} = $self->{results}; + $args{environment}{'@' . $self->{result_name}} = $self->{results}; $next->($line, %args); } @@ -42,7 +44,8 @@ sub mangle_result { my $self = shift; my ($result) = @_; - return '$res[' . $#{ $self->{results} } . '] = ' . $result; + return '$' . $self->{result_name} . '[' . $#{ $self->{results} } . '] = ' + . $result; } 1; |