On 7/31/06, Suraj N. Kurapati <skurapat / ucsc.edu> wrote:

> Agreed. method_missing is certainly the best approach.
>
> def method_missing id, *args, &blk
>   if id =~ /^as_(.*)$/
>     as $1.to_sym, *args, &blk
>   end
> end

This implementation is fine, I just have a slightly different design in mind.
1. I'd like to keep the rubyish semantics of to_s, to_a etc if all I
am doing is a straight conversion.  So i'm going to prefix these w. to
instead of as

2. I don't want these methods to take arguments or blocks, because I
want them to be dumb.  This is just so people go ahead and learn the
much more powerful as() method if they actually need it.

I have added some code that does this, you can see it here.
http://stonecode.svnrepository.com/ruport/trac.cgi/changeset/62

Thanks for the suggestion, I also cleaned up my regex after seeing your code.