--- !ruby/object:RI::ClassDescription attributes: - !ruby/object:RI::Attribute comment: name: decoys rw: R - !ruby/object:RI::Attribute comment: name: ducks rw: R class_methods: - !ruby/object:RI::MethodSummary name: duckcall - !ruby/object:RI::MethodSummary name: new comment: - !ruby/struct:SM::Flow::H level: 1 text: Method Probe - !ruby/struct:SM::Flow::P body: Method::Probe (aka DuckHunter) is a decoy object which is dropped into methods which records the calls made against it --hence a method probe. Of course, it is not perfect --an inescapable matter it seems for any internal probe. There are a couple of issues related to conditionals. Since the method test for a certain condition against the decoy, how is the decoy to respond? Thus ceratin paths in the code may never get exceuted and thus go unmapped. If Ruby had better conditional reflection (i.e. if 'if', 'case', 'unless', 'when', etc. were true methods) then this could be fixed by making the Probe reentrant, mapping out variant true/false/nil replies. The likely insurmountable problem though is the Halting problem. A probe can cause some methods to complete execution. It's pretty rare, but it can happen and little can be done about it (I think). - !ruby/struct:SM::Flow::P body: Note, the alternative to this kind of probe is a program that examines, rather then executes, the code. This would circumvent the above problems, but run into difficulties with dynamic evals. It would also be more complicated, but might prove a better means in the future. - !ruby/struct:SM::Flow::P body: This script is provided for experimetnal purposes. Please inform the author if you find ways to improve it or put it to an interesting use. - !ruby/struct:SM::Flow::H level: 2 text: Synopsis - !ruby/struct:SM::Flow::VERB body: " require 'methodprobe'\n\n def amethod(x)\n x + 1\n end\n\n p method(:amethod).signiture\n p method(:amethod).signiture(:class)\n p method(:amethod).signiture(:pretty)\n" - !ruby/struct:SM::Flow::P body: produces - !ruby/struct:SM::Flow::VERB body: " [["+"]]\n [{"+"=>[["Fixnum"]]}]\n [["+( Fixnum )"]]\n" constants: [] full_name: Quarry::MethodProbe includes: [] instance_methods: - !ruby/object:RI::MethodSummary name: initialize_copy - !ruby/object:RI::MethodSummary name: method_missing name: MethodProbe superclass: Object