Right now I have a series of objects that are created using C extensions, so say they are
- Foo
- Bar
- Baz.
I have ruby code that instantiates the three of them, calls their functions and processed the results. Let's call that:
- Manager
Well, now Manager is my bottleneck, so I'd like to turn it into a C extension. But I don't know how to instantiate Foo, Bar, and Baz from within Manager. Do I have to use code like:
VALUE module_klass = rb_const_get(rb_cObject, rb_intern("Module"));
VALUE object_klass = rb_const_get(module_klass, rb_intern("Foo"));
And then call methods like:
rb_funcall(object_klass, rb_intern("new"), 0);
Or is there a cleaner way?