On Sep 24, 7:40 pm, Tom M [email protected] wrote:
Your suggestion seems to violate the notion of encapsulation. If an
change were to be made, I’d think it would be better to make the error
the same for calling a parent’s private method as it is for calling a
A parent’s private method? I’m not sure I follow. Do you mean
something like the following?
class B < A
b = B.new
Because that’s not calling a parent private method. The private method
is inherited from A and part of B now.
My suggestion might violate encapsulation. It’s not necessary to
change which exceptions are raised, but I am convinced that
method_missing shouldn’t come into the picture when attempting to call
a private or protected method. I took a look at the method_missing
code and it specifically checks for different reasons why the desired
method couldn’t be called, including access level. And it uses the
It seems to me that there are two viewpoints to consider. From outside
the class, there’s no difference between calling a private or
protected method and a method that doesn’t exist: it simply doesn’t
work. But a private method actually exists, so it is not exactly the
same as an undefined method. With that in mind, I go with my feeling
that they should be treated differently.