creating method dynamically

J

John Mair

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,076
Latest member
OrderKetoBeez

Latest Threads

Top