On Feb 17, 2010, at 20:38 , Martin Emde wrote: > You can use @instance variables in classes but they don't work with > inheritance. > http://railstips.org/blog/archives/2006/11/18/class-and-instance-variables-in-ruby/ > is a pretty good explanation.
That *is* a good explanation — this was the first time I'd stumbled on this construct in Rails. I'm starting to arrive at the conclusion that while the syntax and semantics of Ruby are generally great, I'd really rather have the object model from Javascript. Metaprogramming in Ruby is rather a great deal more of a PITA than I think it ought to be, without any obvious gain that I can see. Anyway. In this case, a single shared cache for this was fine (it was actually an instance variable in a module, so it was always the same). The problem wasn't that the cache wasn't working (in that case, it would have just fallen through to the lookup anyway). The problem was that the class pulled from the cache was broken the second time you tried to use it. So I still think the problem was the class reloading in development mode. I just took out the cache, so it's all good now. Thanks all for pitching in. Regards, Guyren G Howe Relevant Logic LLC guyren-at-relevantlogic.com ~ http://relevantlogic.com ~ +1 512 784 3178 Ruby/Rails, REALbasic, PHP programming PostgreSQL, MySQL database design and consulting Technical writing and training Read my book, Real OOP with REALbasic: <http://relevantlogic.com/oop-book/about-the-oop-book.php> -- SD Ruby mailing list [email protected] http://groups.google.com/group/sdruby
