From: mutahhir hayat Date: 2008-03-19T22:31:41+09:00 Subject: Re: Inspetting a method's caller I've always seen that whenever you need something like this, there's always a better design choice that you can make. Like what would you do in languages that didn't have caller etc etc. Its still a hack, (because ideally you shouldn't be needing this IMO), but you can make the caller send in an extra argument, putting its description/ID/Name there. MT On Wed, Mar 19, 2008 at 8:53 PM, Alberto Santini wrote: > Hello. > How can i know a function's caller method? E.g. > > class A > def do_stg(n) > b = B.new > b.do_xyz(n) > end > end > > class B > def do_xyz(n) > # -> Here i want to know that > # -> This method has been called > # -> From A#do_stg > n + 1 > end > end > > Kernel#caller does not help.. i don't care what file or line a function > has been called, and i couldn't find nothing helpful on ruby-doc nor by > searching google :| > Please keep in mind i'd like to know that do_xyz has been called by > do_stg -> WHICH IS A METHOD OF THE "A" CLASS <- > > Thanks for your help :) > -- > Posted via http://www.ruby-forum.com/. > >