Returns an array of method arguments and their default values Example:
class Example def hello(one,two="two",three) end def goodbye end end Example.instance_method(:hello).get_args #=> [[:one], [:two, "two"], [:three, "three"]] Example.instance_method(:goodbye).get_args #=> nil
Source Code
# File merb/core_ext/get_args.rb, line 60 def get_args klass, meth = self.to_s.split(/ /).to_a[1][0..-2].split("#") # Remove stupidity for #<Method: Class(Object)#foo> klass = $` if klass =~ /\(/ ParseTreeArray.translate(Object.const_get(klass), meth).get_args end
<code/>and<pre/>for code samples.