Method: Pry::Method.from_class

Defined in:
lib/pry/method.rb

.from_class(klass, name, target = TOPLEVEL_BINDING) ⇒ Pry::Method? Also known as: from_module

Given a ‘Class` or `Module` and the name of a method, try to instantiate a `Pry::Method` containing the instance method of that name. Return `nil` if no such method exists.

Parameters:

  • klass (Class, Module)
  • name (String)
  • target (Binding) (defaults to: TOPLEVEL_BINDING)

    The binding where the method is looked up.

Returns:



136
137
138
139
140
# File 'lib/pry/method.rb', line 136

def from_class(klass, name, target = TOPLEVEL_BINDING)
  new(lookup_method_via_binding(klass, name, :instance_method, target))
rescue StandardError
  nil
end