I have a module with methods that are logged. In each message I want to put the name of the class that registered this message.
The module can be mixed with includeor extend. I need my journal to have the correct class names in each case.
Distilled Code:
module M
def f
self.class.name
end
end
class C
extend M
include M
end
p C.f
p C.new.f
As you can see, the first call does not print correctly "Class". I want him to be "C".
How to do it?
source
share