From: Gavin Kistner Date: 2004-02-17T22:49:53+09:00 Subject: Re: Hash like JS Hash (code) Claude Brisson wrote: > How would you achieve the same accesses with rexml elements, to access > subelements or attributes ? > > I guess it's possible, but I'm still a ruby newbie... Use the exact same code as I gave for the Hash object, but use the class of your choice there. (To make things really ugly, do this on Object, and EVERYTHING in Ruby will behave this way :p) If you don't need setters, but only accessors via dot notation, it can be simplified to: class SomeClass def method_missing(meth,*args) /=$/=~meth.id2name ? nil : self[meth] end end All this said, you should think hard before you do this, since it will make your code somewhat un-ruby-like; further, you run a strong risk of running into confusing problems, where you think you're accessing a property by name but are in fact invoking a method. -- (-, /\ \/ / /\/