mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
- fix case where literal names wouldn't invoke a block.
thing.call("foo") { ... } would not invoke the block but thing.call("[foo]") would. Both work now and have test cases.
This commit is contained in:
parent
c6e379e931
commit
1d45784c68
1 changed files with 8 additions and 2 deletions
|
@ -3,8 +3,13 @@ require "logstash/util"
|
|||
|
||||
module LogStash::Util::HashEval
|
||||
def compile(str)
|
||||
if str[0] != '['
|
||||
return "lambda { |e, &block| return e[#{str.inspect}] }"
|
||||
if str[0,1] != '['
|
||||
return <<-"CODE"
|
||||
lambda do |e, &block|
|
||||
block.call(e, #{str.inspect}) unless block.nil?
|
||||
return e[#{str.inspect}]
|
||||
end
|
||||
CODE
|
||||
end
|
||||
|
||||
code = "lambda do |e, &block|\n"
|
||||
|
@ -29,6 +34,7 @@ module LogStash::Util::HashEval
|
|||
|
||||
end
|
||||
code << "return e\nend"
|
||||
#puts code
|
||||
return code
|
||||
end # def compile
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue