Method: Pry::Method.all_from_class

Defined in:
lib/pry/method.rb

.all_from_class(klass, include_super = true) ⇒ Array[Pry::Method]

Get all of the instance methods of a ‘Class` or `Module`

Parameters:

  • klass (Class, Module)
  • include_super (Boolean) (defaults to: true)

    Whether to include methods from ancestors.

Returns:



161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/pry/method.rb', line 161

def all_from_class(klass, include_super = true)
  %w[public protected private].flat_map do |visibility|
    safe_send(
      klass, :"#{visibility}_instance_methods", include_super
    ).map do |method_name|
      new(
        safe_send(klass, :instance_method, method_name),
        visibility: visibility.to_sym
      )
    end
  end
end