}
public static IRubyObject defs(ThreadContext context, IRubyObject self, IRubyObject receiver, Object scriptObject, String name, String javaName, String[] scopeNames,
int arity, int required, int optional, int rest, CallConfiguration callConfig) {
Class compiledClass = scriptObject.getClass();
Ruby runtime = context.getRuntime();
RubyClass rubyClass = performSingletonMethodChecks(runtime, receiver, name);
StaticScope scope = creatScopeForClass(context, scopeNames, required, optional, rest);
MethodFactory factory = MethodFactory.createFactory(compiledClass.getClassLoader());
DynamicMethod method = constructSingletonMethod(factory, rubyClass, javaName, arity, scope,scriptObject, callConfig);
rubyClass.addMethod(name, method);
callSingletonMethodHook(receiver,context, runtime.fastNewSymbol(name));
return runtime.getNil();
}