I think I know super intends to override the same method inherited from the parent class.
Actually, it is the opposite. When you override some method in a child class, super
is used to refer to the behaviour of the same method in the parent class (i.e., the original behaviour).
In the given code, the indent is to make it dynamically respondable to any method that starts with foo
without changing the respondability of other methods. The first part is done by:
if method_name.to_s[0,3] == "foo"
true
but if it were only that, all other undefined methods would simply return nil
even if they are defined in some parent class. If some parent class were to respond to such method, then returning nil
to respondability would incorrectly block such methods. The other part:
else
super(method_name)
is to return the correct value for such case. It means that in other cases, do what the parent class did.