class Pry::Method::Disowned

A Disowned Method is one that's been removed from the class on which it was defined.

e.g. class C

def foo
  C.send(:undefine_method, :foo)
  Pry::Method.from_binding(binding)
end

end

In this case we assume that the "owner" is the singleton class of the receiver.

This occurs mainly in Sinatra applications.

Attributes

name[R]
receiver[R]

Public Class Methods

new(receiver, method_name, binding=nil) click to toggle source

Create a new Disowned method.

@param [Object] receiver @param [String] method_name

# File lib/pry/method/disowned.rb, line 23
def initialize(receiver, method_name, binding=nil)
  @receiver, @name = receiver, method_name
end

Public Instance Methods

method_missing(meth_name, *args, &block) click to toggle source

Raise a more useful error message instead of trying to forward to nil.

# File lib/pry/method/disowned.rb, line 47
def method_missing(meth_name, *args, &block)
  raise "Cannot call '#{meth_name}' on an undef'd method." if method(:name).respond_to?(meth_name)
  Object.instance_method(:method_missing).bind(self).call(meth_name, *args, &block)
end
owner() click to toggle source

Get the hypothesized owner of the method.

@return [Object]

# File lib/pry/method/disowned.rb, line 42
def owner
  class << receiver; self; end
end
source?() click to toggle source

Can we get the source for this method? @return [Boolean] false

# File lib/pry/method/disowned.rb, line 35
def source?
  false
end
undefined?() click to toggle source

Is the method undefined? (aka `Disowned`) @return [Boolean] true

# File lib/pry/method/disowned.rb, line 29
def undefined?
  true
end