Something like this?
class A
module ClassMethods
macro method_missing(call)
{% p call %}
end
end
extend ClassMethods
end
A.a
Result of the code is Error : undefined method 'a' for A:Class
. It seems method_missing
doesn't work for class object.
The reason for the question is that I implemented a class with a current
class method to get an instance for current context. For the simplification, I want some like forward_missing_to
to replace MyClass.current.xxx
with MyClass.xxx
, so method_missing
is required according forward_missing_to
's implementation.
I also found, delegate
works fine for class methods using above way. So actually my pratical problem has been solved, but I'm still interesting with the question : method_missing
for class object, is it impossible?