I continue my study on Ruby and another question occurred me. I know that when we define a class method on a class, it's created a singleton class that gets the definition of that method, and from then on, that method is an instance method of that singleton class(i got this conclusion from tests, but i might be wrong, so feel free to correct me).
My question is, how can i call a class method on a class X with X.classMethod if the method is defined on a singleton class as an instance method of that class(i am not asking how can i do it. It is what happens.). It confuses me even more, because i noticed(running some tests) that the singleton class of a class is not even hierarchically related to the class it comes from, so, how is a class method call resolved to the singleton class? And more precisely: how is the class calling a method on a singleton class that is an instance method, without any instance.
I hope i did not confuse you.
Thanks you once more.