From: Didier Prophete Date: 2006-01-18T10:30:05+09:00 Subject: Re: invalid_arity method similar to method missing ? Hi Logan, Thanks for your reply. Well, that doesn't solve my exact problem, but it's something I'll keep in mind. Here is actually what I am trying to do. I have these functions which get their arguments from a 'request' object. Each argument is being extracted one by one like this: def f1 arg1 = requests[:arg1] arg2 = requests[:arg2] end These functions are called by another class which populates the request object (actually this is some rails code but the problem is not bound to rails itself...). Now obviously, this is a little bit of a pain. It would be much easier to simply write all these function like this, with real parameters: def f1(arg1, arg2) end (I am using f1, and arg1 and arg2, but actually you have more than one of these functions and the number of arguments is variable...) So my initial idea was to do something like: if the caller class calls f1 with the wrong number of argument (zero in my case): look at the names of the parameters of the f1 extract value for these arguments from the request object call f1 with the right parameters end Now it turns out that the caller class always uses 'send' to call f1, so I don't quite need a generic 'invalid_arity' method anymore since I can just check for the arity of the function being called right before using 'send' But now my new problem is trying to get the argument names of a given function. I haven't found a way to do that... I posted a msg on this forum but didn't get any reply so far... The best I can do is get a handle to the 'method' object. Something like: meth = self.method(:f1) But I am stuck there... I would need something like: meth.arg_list which would return [ :arg1, :arg2 ], or something like that. I am not even sure this is possible in ruby... -Didier -- Posted via http://www.ruby-forum.com/.