ts wrote:

>>>>>> "J" == Joel VanderWerf <vjoel / path.berkeley.edu> writes:
> 
> J> Why can't a class method call a protected instance method, as in the
> J> following example?
> 
>  Try this
....
>        foo.send :prot_meth

But that can be done from any context, not just class methods of the same 
class.

Anyway, I wasn't really looking for a way to break encapsulation, I just 
thought class methods would have higher privileges with respect to the 
class's own encapsulation.

That brings up a question about breaking encapsulation: Why is this code 
allowed:

  f = Foo.new
  f.instance_eval { @x = 1}

but not this:

  f.instance_eval { prot_meth }

It seems that the ways to break encapsulation are not really  consistent. 
On one hand, instance_eval can access attributes, but not  protected 
methods. On the other hand, send can access protected methods,  but not 
attributes. 

Is there any way to access both, short of eval-ing  a new method definition 
in the class?