On Aug 3, 9:59 am, "ara.t.howard" <ara.t.how... / gmail.com> wrote:
> On Aug 3, 2007, at 7:19 AM, Peter Laurens wrote:
>
>
>
> > Hi,
>
> > I am not having much luck in finding out how to get the calling object
> > of a method.
>
> > Is there an implicit way that a method can get a pointer to the object
> > that called it, or do I have to write that explicitly, manually
> > including a 'sender' parameter for the method call myself?
>
> > I have looked at 'caller' but can only coax a string out of it.
>
> > Thanks in advance for your kind help!
>
> > - Nex
> > --
> > Posted viahttp://www.ruby-forum.com/.
>
> in many contexts this will work:
>
> require 'binding_of_caller'
>
> def method
>    caller = Binding_of_caller{|binding| eval 'self', binding}
> end
>
> notably NOT class methods though...


  You can always take a block and get the binding from it:

  def method(&b)
    callers_binding = b.send(:binding)
  end

I works always. Yes, it means passing a block, but sometimes that's
useful anyway.

T.