From: Robert Klemme Date: 2005-05-30T00:20:20+09:00 Subject: Re: method visibility > > "Bob Aman" schrieb im Newsbeitrag > news:599af4e205052813201d9720d8@mail.gmail.com... > More nubyness. Apologies. > > Ok, so, I have this rss feed caching system i'm working on. Ideally, > I'd like to have as little of the internal workings of the thing > visible as possible. I just want the programmer to interact with Feed > and FeedItem objects, not the caching mechanisms. > > It seems to me that I don't really want the programmer to be able to > create instances of a FeedItem manually. All FeedItems ought to be > created automatically by a Feed object. But it seems like ruby lacks > the direct equivalent of c++'s "friend", so I guess I can't give > access to the "new" class method only to Feed. > > Also, I'd like to make the caching mechanism be changable. It'd be > nice to be able to switch between, say, a database-based cache and a > file system-based cache. Perhaps like this: > > FeedCache.cache_type = :DatabaseFeedCache Why not just assign a proper cache instance to a global variable or to a feed (whatever is more appropriate)? > And then the Feed object would simply use the DatabaseFeedCache behind > the scenes. But again, I'm not sure how to make the cache's behavior > available only to the Feed and FeedItem classes (or even if I can). I wouldn't mind too much about the accessibility stuff. If someone wants to circumvent things this is easy in Ruby so just see that your class design is appropriate and go ahead. My 0.02 EUR... Kind regards robert