From: "Mauricio Fernández" Date: 2003-03-28T17:35:44+09:00 Subject: Re: Conditionally make a method private? On Fri, Mar 28, 2003 at 11:35:56AM +0900, Jeremy wrote: > 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...? Just that :) One last thing though: you should probably pass references around instead of simply using a global (even if they all come from, say, GlobalState.instance), for this way you'll be able to change associations easily in the future... ie. class Foo def initialize( ... state ) @state = state end def foo #use @state end end instead of "hardwiring" class Foo def foo #use $state end end -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com Sex dumps core (Sex is a Simple editor for X11) -- Seen on debian bugtracking