From: Francis Hwang Date: 2004-11-21T10:35:02+09:00 Subject: Re: Inner Class Relationship On Nov 20, 2004, at 7:22 PM, James Edward Gray II wrote: > On Nov 20, 2004, at 5:55 PM, Francis Hwang wrote: > >> Since you haven't said much about how you're using this, maybe my >> answer will be a little presumptive, but: Is there are a particular >> reason you want the inner class to relate to the outer class this >> way? > > Yes. > > Even if I separate the two classes, my questions remain unchanged: > What's a good way to allow one type of object to send private-ish > messages to another type of object? > > As for details: My outer class is a server. My inner class is a > connection for that server. When a connection ends, I need a way to > notify the Server object to remove it from it's maintenance list. > That's the message I'm wanting to hide from the outside world. > Maybe part of the question has to do with the nature of private-ness in Ruby .... I don't think it's easy in Ruby to have a sort of C++-like friend relationship, where you privilege certain classes to call certain methods. (I did something like this in my ContextualService classes for Lafcadio, by checking caller, but it's sort of a kludge and I wouldn't necessarily recommend it for general use.) But then, what do we mean by private? What if you just hid the method in the RDoc? Do you imagine a situation where people might use it incorrectly, either by accident or maliciously? This differs depending on how the code's going to be used, of course. Also, have you considered using Observable? Francis Hwang http://fhwang.net/