Method: Pry::Method::WeirdMethodLocator.normal_method?

Defined in:
lib/pry/method/weird_method_locator.rb

.normal_method?(method, binding) ⇒ Boolean

Whether the given method object matches the associated binding. If the method object does not match the binding, then it’s most likely not the method captured by the binding, and we must commence a search.

Parameters:

Returns:

  • (Boolean)


29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pry/method/weird_method_locator.rb', line 29

def normal_method?(method, binding)
  if method && method.source_file && method.source_range
    if binding.respond_to?(:source_location)
      binding_file, binding_line = binding.source_location
    else
      binding_file = binding.eval('__FILE__')
      binding_line = binding.eval('__LINE__')
    end
    (File.expand_path(method.source_file) == File.expand_path(binding_file)) &&
      method.source_range.include?(binding_line)
  end
rescue StandardError
  false
end