lib/grok-pure.rb in jls-grok-0.11.1 vs lib/grok-pure.rb in jls-grok-0.11.2
- old
+ new
@@ -142,10 +142,15 @@
when "int"; ".to_i"
when "float"; ".to_f"
else; ""
end
name = pattern if name.nil?
- re_match << " block.call(#{name.inspect}, match[#{index}]#{coerce})"
+ if coerce
+ re_match << " m = match[#{index}]"
+ re_match << " block.call(#{name.inspect}, (m ? m#{coerce} : m))"
+ else
+ re_match << " block.call(#{name.inspect}, match[#{index}])"
+ end
end
end
re_match << "end"
return eval(re_match.join("\n"))
end # def compile_captures_func