From: Macario Ortega Date: 2008-10-29T02:52:02+09:00 Subject: Re: Named arguments gem Roger Pack wrote: >> require 'named_arguments' >> >> class Example >> >> def another_instance_method( a = :a, b = :b, c = :c) >> [a,b,c] >> end >> >> named_args_for :instance_method, :another_instance_method > > How fascinating that your and my project would arrive at almost the same > spot from [seemingly] different angles. LOL. > > http://code.google.com/p/ruby-roger-useful-functions/wiki/NamedParameters > > It would be interesting to compare the two. Perhaps we should combine > projects. > > One thing to also look out for is if it works appropriately with blocks. > > I think the next step for this type of project is to have it fallback to > ruby_parser [which just now started to work with 1.9]. We could thus > use #UnboundMethod.source_location to try and parse the original source. > Then it could work with 1.9 > Cheers! > -=R Yeah, both solutions look similar. I had a very specific need where I had a set of methods where I needed to pass just certain literal (sybols and numbers) arguments so at one point I realized my solution worked only with literals, I've fixed this using object_id and ObjectSpace._id2ref for that object id. I've been a Rails user for a while and just recently I had this epiphany where spec driven development came into place and i understood what metaprogramming was, just when i started to feel all there was ahead was convention over configuration. I havent tried to make it work with blocks or with ruby 1.9, actually I haven't toyed with ruby 1.9 but yeah let's make it work with 1.9 and blocks. Cheers -- Posted via http://www.ruby-forum.com/.