From 61a9d9689be7720a8345b7ff35f08041134cc15e Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Sat, 13 Feb 2016 00:21:25 +0100 Subject: scanner tweaks --- lib/coderay/rule_based_scanner.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/coderay/rule_based_scanner.rb') diff --git a/lib/coderay/rule_based_scanner.rb b/lib/coderay/rule_based_scanner.rb index ac6a623..9239cf6 100644 --- a/lib/coderay/rule_based_scanner.rb +++ b/lib/coderay/rule_based_scanner.rb @@ -219,18 +219,20 @@ module CodeRay protected - def make_callback block + def callbacks @callbacks ||= {} - + end + + def make_callback block base_name = "__callback_line_#{block.source_location.last}" name = base_name counter = 'a' - while @callbacks.key?(name) + while callbacks.key?(name) name = "#{base_name}_#{counter}" counter.succ! end - @callbacks[name] = define_method(name, &block) + callbacks[name] = define_method(name, &block) arguments = block.parameters.map(&:last) -- cgit v1.2.1