I’m reading the book “Well Grounded Rubyist” and I have a question about the method-lookup path:
module M
def report
puts "'report' method in module M"
end
end
module N
def report
puts "'report' method in module N"
end
end
class C
include M
include N
def report
puts "'report' method in class C"
puts "About to call super..."
super
puts "Back from super..."
end
end
obj = C.new
obj.report
Based on my understanding, obj.report will output:
'report' method in class C
About to call super...
'report' method in module N
Back from super...
However, I’m curious if it’s possible to call M’s report method, by bypassing N’s report, from within class C. I know if I add “super” within module N, it’ll call N’s report and then M’s report before putting “Back from super…” but is there a way to do this directly from C?
You can use ancestor reflection: