mirror of
https://github.com/elastic/logstash.git
synced 2025-04-25 07:07:54 -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
|
module LogStash::Util::HashEval
|
||||||
def compile(str)
|
def compile(str)
|
||||||
if str[0] != '['
|
if str[0,1] != '['
|
||||||
return "lambda { |e, &block| return e[#{str.inspect}] }"
|
return <<-"CODE"
|
||||||
|
lambda do |e, &block|
|
||||||
|
block.call(e, #{str.inspect}) unless block.nil?
|
||||||
|
return e[#{str.inspect}]
|
||||||
|
end
|
||||||
|
CODE
|
||||||
end
|
end
|
||||||
|
|
||||||
code = "lambda do |e, &block|\n"
|
code = "lambda do |e, &block|\n"
|
||||||
|
@ -29,6 +34,7 @@ module LogStash::Util::HashEval
|
||||||
|
|
||||||
end
|
end
|
||||||
code << "return e\nend"
|
code << "return e\nend"
|
||||||
|
#puts code
|
||||||
return code
|
return code
|
||||||
end # def compile
|
end # def compile
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue