Hi there,

> $ jruby --1.9 -S irb
> irb(main):001:0> lambda {|arg1, arg2, arg3=true, *rest|}.parameters
> => [[:req, :arg1], [:req, :arg2], [:opt, :arg3], [:rest, :rest]]
That's exactly what I needed and really easy to use. I do not have a
problem to be only 1.9.x compatible.
>From the RubyClass object, how do I get to this "parameters" method? I
did not see it in the API and that is surely my fault.

Werner, thanks for correcting it and as you mentioned, Asari's
implementation seem to fit perfectly. For us who are trying to mix
dependency injection within Ruby code that's the simplest and most CoC
way to do it.

Regards

Guilherme Silveira
Caelum | Ensino e Inovação
http://www.caelum.com.br/



On Mon, Nov 15, 2010 at 2:35 PM, Hirotsugu Asari <[email protected]> wrote:
>
> On Nov 15, 2010, at 8:11 AM, Werner Schuster (murphee) wrote:
>
>> On 11/15/10 4:58 PM, Guilherme Silveira wrote:
>>> Thanks Roland,
>>>
>>> ParseTree and Ripper are file source parsers,
>> That's incorrect for ParseTree, which essentially just turned MRI's AST
>> into a Ruby data structure, ie. it worked at runtime without looking at the
>> source.
>> Merb had a feature, long ago, called action arguments, which used
>> ParseTree to get at argument names (the docu link is gone, but I wrote about
>> it here http://www.infoq.com/news/2009/07/ruby192-preview1-rubyversions )
>>
>> There's a JRuby version of ParseTree (oddly named 'jParseTree') that I
>> wrote a few years ago, but it hasn't been updated in quite a while, and
>> probably doesn't run in its current state (unless the JRuby AST has been
>> stable for the last 3 years).
>>
>> Hm... come to think of it... this
>> http://www.infoq.com/news/2009/07/ruby192-preview1-rubyversions   mentions
>> that Ruby 1.9.2 might get Method#parameters, which should do what you want.
>> No idea about the status of this right now;
>>
>
> I implemented it earlier this year.
>
> $ jruby --1.9 -S irb
> irb(main):001:0> lambda {|arg1, arg2, arg3=true, *rest|}.parameters
> => [[:req, :arg1], [:req, :arg2], [:opt, :arg3], [:rest, :rest]]
> irb(main):002:0> def func(arg1, arg2, arg3=true, *rest); end
> => nil
> irb(main):003:0> method(:func).parameters
> => [[:req, :arg1], [:req, :arg2], [:opt, :arg3], [:rest, :rest]]
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to