From: "Dermot C." Date: 2013-05-17T02:32:46+09:00 Subject: Re: using the current method name within current method 7stud -- wrote in post #1083904: >> Using caller does give me the name of the calling method, but there is >> no reference to what module or class that method belonged to. Is that >> possible to obtain? > > def get_mname > caller[0]=~/`(.*?)'/ # note the first quote is a backtick > $1 > end > > def dinosaur > puts get_mname > puts method(get_mname).owner > end > > dinosaur > > --output:-- > dinosaur > Object Guys, FYI caller doesn't give meaningful data about method when the method is called from a bare file, e.g. a Cucumber Step definition. Instead of giving common_steps.rb:42:in `some_method_or_other' ... it gives common_steps.rb:42:in `block in ' ... For these situations you're better off using __method__ and self.name.to_s if you also need the class in which the method is contained. HTH, Dermot -- Posted via http://www.ruby-forum.com/.