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.
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.
Depends on what you want to do. If it’s for debugging purposes you
can use set_trace_func to keep track of callers or just trace the
whole program execution.
If you need it for your program logic then you should pass the caller
either as method parameter or set it as an attribute before the
call. Depends on what you do which is more appropriate.
Hmm maybe binding_of_caller might help, as far as I know Facet
implements it, and Why did so too, maybe just google it, I would not
know which one to recommend.
I am not having much luck in finding out how to get the calling object
of a method.
I’m not sure to understand what you mean, because inside a method
“meth”, which is used/called by an object “obj” by “obj.meth”, the
object can be referenced by “self”.
Hmm maybe binding_of_caller might help, as far as I know Facet
implements it, and Why did so too, maybe just google it, I would not
know which one to recommend.
IIRC, binding of caller hasn’t worked since 1.8.4. It relied on a bug
that was fixed.
Hmm maybe binding_of_caller might help, as far as I know Facet
implements it, and Why did so too, maybe just google it, I would not
know which one to recommend.
IIRC, binding of caller hasn’t worked since 1.8.4. It relied on a bug
that was fixed.
My mistake, I was thinking of Binding#of_caller, which was a different
thing, heh.