Check Global method exist inside a class method

Hi all,
I have a problem in identifying whether a global method exist or not,
from inside class, My code is similar to,

Here "respond_to?("myMethod")" fails, It seems to be only checking the
methods inside the class, not global methods.

top levels methods like that aren't 'global' methods, they end up as
private methods on Object.

Fred

Hi Frederick,

Did you mean I should check with, Object.respond_to?("myMethod"). But
It still it didnt' work. Is that the Object you mention is not what I
mean here?
Can you please explain it little bit more?

Thanks
Dimuthu

Hi Frederick,

Did you mean I should check with, Object.respond_to?("myMethod"). But
It still it didnt' work. Is that the Object you mention is not what I
mean here?
Can you please explain it little bit more?

by default, respond_to doesn't check for private methods, but you can
force it : Object.respond_to?(:myMethod, true)

Fred

Thanks, It works

Dimuthu