On Fri, 4 Feb 2005 05:10:59 +0900, Ryan Davis <ryand / zenspider.com> wrote:
> 
> On Feb 3, 2005, at 11:51 AM, Joe Van Dyk wrote:
> 
> > Here's what I have so far.  This works, but wondering if something
> > better's out there.
> >
> >     def method_missing(method, *args)
> >         puts "method missing called with #{method} and #{args}"
> >
> >         if method.to_s =~ /^(.+)=$/
> >             set($1.to_sym, *args)
> >         else
> >             get(method.to_sym)
> >         end
> >     end
> 
> That looks fine to me. I, by habit/musclememory, use intern instead of
> to_sym. You shouldn't need to do it for your get as method_missing
> should be passed a symbol in the first place.


Thanks for the input.  My previous function failed on code like

assert(my_obj.x_pos == 10)

so I needed to add an

elsif method.to_s =~ /^(.+)==$/
  get($1.to_sym)

to SomeObject#method_missing.