From: Jeremy Date: 2003-03-28T11:35:56+09:00 Subject: Re: Conditionally make a method private? Mauricio Fern�ndez wrote: > On Thu, Mar 27, 2003 at 10:50:44AM +0900, Jeremy wrote: >> dblack@superlink.net wrote: >> Actually, if I understand what you are saying, this is EXACTLY what I >> want. What I was trying to accomplish was having an attribute that wasn't >> quite >> global, but more accessable than just a normal class attribute. I do >> want > > But in a way it *is* global, as there's only one class attribute, it is > simply scoped into that class. Every pair of database/menu objects will > be using the same attribute. True. And that's pretty much what I need. One to be shared among all, (as opposed to each pair sharing their own) but only among all specified objects. There are other objects, such as books, teachers, and such, that do not (and should not) need access to this. Also, this was a simplified example. Yes, here I did have just one class attribute in use, but in actuality, there are several in use that are all being processed in one way or another. > > If all you want is to share some part of the internal state, you can > simply externalize it as a separate object and keep as many references as > needed. Externalize? I'm not sure exactly how you mean this. Are you talking about releasing the information as some global object? Or am I just way off here...? >> M1's view of the status to change when I change it in M2. I think that >> the best way to think of it is like this: >> >> I have two classes (a database class, and a menu class) that are >> different enough that it doesn't warrant doing inheritance from a single >> superclass, >> but I need any instances of the two classes to communicate directly. I >> didn't really want to muck up global space with an attribute, because I >> don't want all things to be able to access it. But I also didn't want to >> do a lot of hardcoding in each class to make them "aware" of each other. >> I >> wanted this to kind of act like a community whiteboard. Also, I needed >> something that could possibly "do more", such as formatting, or automatic >> message clearing, or things like that. Using the above code was about >> the >> best that I could come up with for such a beast. As stated in the >> message to John Johnson, the reasoning for the original posting was to >> see if I could have some of them to act only as senders of messages (the >> databases), >> and some as readers of messages (the menus). I still would like to do >> something like that, but that will take a bit more thinking for me yet. >> I'm still fresh meat in the ruby community, only having been using it for >> about 3 weeks now. > > Now all this about writers and readers reminds me the Databus being used > by Freeride. In believe it probably what you want (esp. the "act like a > community whiteboard" part :) > > http://www.rubyide.org/cgi-bin/wiki.pl?Databus > > "The FreeBASE Databus is the internal mechanism through which plugins > communicate with each other. It is a hierarchical publish/subscribe > system that combines the features of a data repository and a messaging > system. > > [...] > > The Databus uses a publish/subscribe mechanism that allows you to use > the Databus as a messaging system. You can subscribe to any slot in the > Databus to receive notifications whenever that slot changes." Wow. Good stuff. I think it's a bit more complicated than what I need, but I'll take a closer look at it. Thanks for the info. Jeremy