Is anyone currently working on or have any ideas regarding the
implementation of Module::module_function?
(this is where I’m currently stuck in trying to execute setup.rb for

module_function is meant to take a list of names of instance methods and
make then also callable as class (or singleton) methods.

It’s easy enough to locate the existing methods using something like:

RubyMethodInfo method =

(BTW, why doesn’t ResolveMethod return a RubyMethodInfo?)

However, I’m not entirely sure how to programmatically create a new
class method
(in Ruby.NET we had a helper method that would create a singleton for a
module if one didn’t already exist, but I’m not sure what the equivalent
of this is in IronRuby)

Anyway, it seems that invoking:

module.SingletonClass.DefineMethod( …)

creates a new method in the right place (provided SingletonClass has
been properly initialized).

However, when I try calling such a method as a class method I get a
wrong number of arguments exception, presumably because different
parameters are expected depending on whether it is called as an instance
method or as a class method.

Any ideas?

Cheers, Wayne.

I know that a IronRuby expects singleton methods to have a signature of
SomeReturnType MySingletonMethod(CodeContext context, RubyClass
klass, Other parameters, …)
And if you don’t create them like this, e.g. forget the context or klass
parameters you do get this problem.
And instance methods, canonically to have the form
SomeReturnType MyInstanceMethod(CodeContext context, object self,
Other parameters, …)
Although instance methods seem to be more resilient to alternatives,
such as
not including the context parameter.

I suspect that you will need to create a wrapper method around the
that you are converting in module_function so that it has the correct

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs