Method: Fast.build_grouped_search

Defined in:
lib/fast.rb

.build_grouped_search(method_name, pattern, on_result) ⇒ Proc

Returns binding ‘pattern` argument from a given `method_name`.

Parameters:

  • method_name (Symbol)

    with ‘:capture_file` or `:search_file`

  • pattern (String)

    to match in a search to any file

  • on_result (Proc)

    is a callback that can be notified soon it matches

Returns:

  • (Proc)

    binding ‘pattern` argument from a given `method_name`.



213
214
215
216
217
218
219
220
221
222
# File 'lib/fast.rb', line 213

def build_grouped_search(method_name, pattern, on_result)
  search_pattern = method(method_name).curry.call(pattern)
  proc do |file|
    results = search_pattern.call(file)
    next if results.nil? || results.empty?

    on_result&.(file, results)
    { file => results }
  end
end