Suppose I have:
class A
include B
include C
end
module B
def test_method
puts "Executed second"
end
end
module C
def super_calling
proc { super }
end
def test_method
"Executed first"
super_calling.call
end
end
I expected to execute the block proc { super } in context of the function C::test_method, so that B::test_method would have been invoked, but I get an error that says something like: "super_calling has not superclass" or something like that (don't remember exactly).
Everything works fine (no wonder) if C::test_method is defined like this:
def test_method
"Executed first"
super
end
My question is - I'm asking too much from Ruby or there is something I don't understand? Can someone shed light on it?
Remove whole super_calling and just use super from within the C::test_method.
It will call B::test_method at that point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With