Fix default inspect for Ruby 2.1
In Ruby 2.1, the ancestor list of a singleton class includes the singleton as the first element, so we need to filter it out.
This commit is contained in:
parent
add29398f0
commit
4aed2ab1c0
|
@ -37,8 +37,9 @@ class Pry
|
|||
|
||||
# Read the class name off of the singleton class to provide a default
|
||||
# inspect.
|
||||
eig = class << obj; self; end
|
||||
klass = Pry::Method.safe_send(eig, :ancestors).first
|
||||
singleton = class << obj; self; end
|
||||
ancestors = Pry::Method.safe_send(singleton, :ancestors)
|
||||
klass = ancestors.reject { |k| k == singleton }.first
|
||||
obj_id = obj.__id__.to_s(16) rescue 0
|
||||
str = "#<#{klass}:0x#{obj_id}>"
|
||||
|
||||
|
|
Loading…
Reference in New Issue