public static Object convertProcToInterface(ThreadContext context, RubyBasicObject rubyObject, Class target) {
Ruby runtime = context.runtime;
RubyModule javaInterfaceModule = (RubyModule)Java.get_interface_module(runtime, JavaClass.get(runtime, target));
if (!((RubyModule) javaInterfaceModule).isInstance(rubyObject)) {
javaInterfaceModule.callMethod(context, "extend_object", rubyObject);
javaInterfaceModule.callMethod(context, "extended", rubyObject);
}
if (rubyObject instanceof RubyProc) {
// Proc implementing an interface, pull in the catch-all code that lets the proc get invoked
// no matter what method is called on the interface