mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Support $ <object>::<method> [Fixes #719]
This commit is contained in:
parent
7547b8ca16
commit
1ffae5ebdd
2 changed files with 8 additions and 2 deletions
|
@ -42,8 +42,8 @@ class Pry
|
|||
elsif name.to_s =~ /(.+)\#(\S+)\Z/
|
||||
context, meth_name = $1, $2
|
||||
from_module(target.eval(context), meth_name, target)
|
||||
elsif name.to_s =~ /(.+)\.(\S+)\Z/
|
||||
context, meth_name = $1, $2
|
||||
elsif name.to_s =~ /(.+)(\.|::)(\S+)\Z/
|
||||
context, meth_name = $1, $3
|
||||
from_obj(target.eval(context), meth_name, target)
|
||||
elsif options[:instance]
|
||||
from_module(target.eval("self"), name, target)
|
||||
|
|
|
@ -73,6 +73,12 @@ describe Pry::Method do
|
|||
meth = Pry::Method.from_str("klass.meth#initialize", Pry.binding_for(binding))
|
||||
meth.name.should == "initialize"
|
||||
end
|
||||
|
||||
it 'should look up methods using instance::bar syntax' do
|
||||
klass = Class.new{ def self.meth; Class.new; end }
|
||||
meth = Pry::Method.from_str("klass::meth", Pry.binding_for(binding))
|
||||
meth.name.should == "meth"
|
||||
end
|
||||
end
|
||||
|
||||
describe '.from_binding' do
|
||||
|
|
Loading…
Reference in a new issue