diff options
author | Conrad Irwin <conrad.irwin@gmail.com> | 2012-11-13 20:32:31 -0800 |
---|---|---|
committer | Conrad Irwin <conrad.irwin@gmail.com> | 2012-11-13 20:32:31 -0800 |
commit | 1ffae5ebddcfdc96ea10f9a43ce0caf7fef7b00c (patch) | |
tree | d1bade22a3d08ff678f5eeb00e4dfebcd9987323 | |
parent | 7547b8ca16f4c981062957211b753127adaa565c (diff) | |
download | pry-1ffae5ebddcfdc96ea10f9a43ce0caf7fef7b00c.tar.gz |
Support $ <object>::<method> [Fixes #719]
-rw-r--r-- | lib/pry/method.rb | 4 | ||||
-rw-r--r-- | test/test_method.rb | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/pry/method.rb b/lib/pry/method.rb index 29426d3a..e72b7b4f 100644 --- a/lib/pry/method.rb +++ b/lib/pry/method.rb @@ -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) diff --git a/test/test_method.rb b/test/test_method.rb index 17e781aa..34af0714 100644 --- a/test/test_method.rb +++ b/test/test_method.rb @@ -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 |