mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Make "ls" robust to overridden send
This commit is contained in:
parent
8c6a946181
commit
c211912a72
3 changed files with 9 additions and 4 deletions
|
@ -179,8 +179,8 @@ class Pry
|
|||
end
|
||||
|
||||
if show_ivars
|
||||
output_variables("instance variables", obj.send(:instance_variables))
|
||||
output_variables("class variables", (Module === obj ? obj : obj.class).send(:class_variables))
|
||||
output_variables("instance variables", obj.__send__(:instance_variables))
|
||||
output_variables("class variables", (Module === obj ? obj : obj.class).__send__(:class_variables))
|
||||
end
|
||||
|
||||
if show_locals
|
||||
|
|
|
@ -121,8 +121,8 @@ class Pry
|
|||
# N.B. we pre-cache the visibility here to avoid O(N²) behaviour in "ls".
|
||||
def all_from_common(obj, method_type)
|
||||
%w(public protected private).map do |visibility|
|
||||
obj.send(:"#{visibility}_#{method_type}s").map do |method_name|
|
||||
new(obj.send(method_type, method_name), :visibility => visibility.to_sym)
|
||||
obj.__send__(:"#{visibility}_#{method_type}s").map do |method_name|
|
||||
new(obj.__send__(method_type, method_name), :visibility => visibility.to_sym)
|
||||
end
|
||||
end.flatten(1)
|
||||
end
|
||||
|
|
|
@ -163,6 +163,11 @@ describe Pry::Method do
|
|||
@obj = Class.new{ class << self; def meth; 1; end; end }.new
|
||||
Pry::Method.all_from_obj(@obj).map(&:name).should.not.include('meth')
|
||||
end
|
||||
|
||||
it "should work in the face of an overridden send" do
|
||||
@obj = Class.new{ def meth; 1; end; def send; raise EOFError; end }.new
|
||||
should_find_method('meth')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'on classes' do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue