Fix show-source and show-doc on __binding__/__binding_impl__
This commit is contained in:
parent
9c1a2b34d8
commit
ac68f843a3
|
@ -52,7 +52,7 @@ class Object
|
|||
end
|
||||
|
||||
unless respond_to?(:__binding_impl__)
|
||||
binding_impl_method = <<-METHOD
|
||||
binding_impl_method = [<<-METHOD, __FILE__, __LINE__ + 1]
|
||||
# Get a binding with 'self' set to self, and no locals.
|
||||
#
|
||||
# The default definee is determined by the context in which the
|
||||
|
@ -73,14 +73,14 @@ class Object
|
|||
# it has the nice property that we can memoize this check.
|
||||
begin
|
||||
# instance_eval sets the default definee to the object's singleton class
|
||||
instance_eval binding_impl_method
|
||||
instance_eval *binding_impl_method
|
||||
|
||||
# If we can't define methods on the Object's singleton_class. Then we fall
|
||||
# back to setting the default definee to be the Object's class. That seems
|
||||
# nicer than having a REPL in which you can't define methods.
|
||||
rescue TypeError
|
||||
# class_eval sets the default definee to self.class
|
||||
self.class.class_eval binding_impl_method
|
||||
self.class.class_eval *binding_impl_method
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ class Pry
|
|||
#
|
||||
def from_binding(b)
|
||||
meth_name = b.eval('__method__')
|
||||
if [:__script__, nil, :__binding__, :__binding_impl__].include?(meth_name)
|
||||
if [:__script__, nil].include?(meth_name)
|
||||
nil
|
||||
else
|
||||
method = begin
|
||||
|
|
|
@ -79,10 +79,6 @@ describe Pry::Method do
|
|||
Pry::Method.from_binding(Class.new{ def self.foo; binding; end }.foo).name.should == "foo"
|
||||
end
|
||||
|
||||
it 'should NOT find a method from the special pry bindings' do
|
||||
Pry::Method.from_binding(5.__binding__).should == nil
|
||||
end
|
||||
|
||||
it 'should NOT find a method from the toplevel binding' do
|
||||
Pry::Method.from_binding(TOPLEVEL_BINDING).should == nil
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue