Creating method dynamically

Hello i have the following ruby code, to create class method dynamically
for my module M:

module M
def self.create_method(name, &block)
eigen=class << self; self; end

eigen.module_eval do
  define_method(name, &block)
end

end
end

Now i am writing a C extension and need exactly this functionality for
my C version of create_method() how do i do it in C? rb_define_method()
expects a pointer to a C function, but i want to define a new method
that takes a rubyblock instead, so i think rb_define_method() is not the
right route.

Any help would be very much appreciated,

john

On Sep 4, 2008, at 06:14 , John M. wrote:

end
end
end

Now i am writing a C extension and need exactly this functionality for
my C version of create_method() how do i do it in C?

go read the C code for define_method.

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