mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Pry::Method: added wrapped() method to return underlying Method object
Also using safe_send() to invoke owner.instance_method as owner.instance_method is not guaranteed to exist if a user redefines it (this caused a failing test).
This commit is contained in:
parent
64f2df5e0f
commit
4686de3d9b
1 changed files with 9 additions and 1 deletions
|
@ -18,6 +18,7 @@ class Pry
|
|||
# to provide extra functionality useful to Pry.
|
||||
class Method
|
||||
extend Helpers::BaseHelpers
|
||||
include Helpers::BaseHelpers
|
||||
include RbxMethod if Helpers::BaseHelpers.rbx?
|
||||
include Helpers::DocumentationHelpers
|
||||
|
||||
|
@ -243,6 +244,12 @@ class Pry
|
|||
@wrapped_owner ||= Pry::WrappedModule.new(owner)
|
||||
end
|
||||
|
||||
# Get underlying object wrapped by this Pry::Method instance
|
||||
# @return [Method, UnboundMethod, Proc]
|
||||
def wrapped
|
||||
@method
|
||||
end
|
||||
|
||||
# Is the method undefined? (aka `Disowned`)
|
||||
# @return [Boolean] false
|
||||
def undefined?
|
||||
|
@ -507,7 +514,8 @@ class Pry
|
|||
end
|
||||
next_owner = ancestors[i] or return nil
|
||||
end
|
||||
next_owner.instance_method(name) rescue nil
|
||||
|
||||
safe_send(next_owner, :instance_method, name) rescue nil
|
||||
end
|
||||
|
||||
# @param [String] first_ln The first line of a method definition.
|
||||
|
|
Loading…
Reference in a new issue