Method: Pry::Command::ShowInfo#code_object_with_accessible_source

Defined in:
lib/pry/commands/show_info.rb

#code_object_with_accessible_source(code_object) ⇒ Pry::WrappedModule, ...

This method checks whether the ‘code_object` is a WrappedModule, if it is, then it returns the first candidate (monkeypatch) with accessible source (or docs). If `code_object` is not a WrappedModule (i.e a method or a command) then the `code_object` itself is just returned.



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/pry/commands/show_info.rb', line 61

def code_object_with_accessible_source(code_object)
  return code_object unless code_object.is_a?(WrappedModule)

  candidate = code_object.candidates.find(&:source)
  return candidate if candidate

  raise CommandError, no_definition_message unless valid_superclass?(code_object)

  @used_super = true
  code_object_with_accessible_source(code_object.super)
end