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
Public Class Methods
Source
# File lib/pry/method/disowned.rb, line 25 def initialize(receiver, method_name) @receiver = receiver @name = method_name @method = nil end
Create a new Disowned
method.
@param [Object] receiver @param [String] method_name
Public Instance Methods
Source
# File lib/pry/method/disowned.rb, line 52 def method_missing(method_name, *args, &block) if method(:name).respond_to?(method_name) raise "Cannot call '#{method_name}' on an undef'd method." end method = Object.instance_method(:method_missing).bind(self) method.call(method_name, *args, &block) end
Raise a more useful error message instead of trying to forward to nil. rubocop:disable Style/MethodMissingSuper
Source
# File lib/pry/method/disowned.rb, line 46 def owner class << receiver; self; end end
Get the hypothesized owner of the method.
@return [Object]
Source
# File lib/pry/method/disowned.rb, line 62 def respond_to_missing?(method_name, include_private = false) !method(:name).respond_to?(method_name) || super end
rubocop:enable Style/MethodMissingSuper
Calls superclass method
Pry::Method#respond_to_missing?
Source
# File lib/pry/method/disowned.rb, line 39 def source? false end
Can we get the source for this method? @return [Boolean] false
Source
# File lib/pry/method/disowned.rb, line 33 def undefined? true end
Is the method undefined? (aka ‘Disowned`) @return [Boolean] true