/** * Attaches this function to a ruby module or class. * * @param module The module or class to attach the function to. * @param methodName The ruby name to attach the function as. */ @JRubyMethod(name="attach") public IRubyObject attach(ThreadContext context, IRubyObject obj, IRubyObject methodName) { DynamicMethod m = createDynamicMethod(obj.getSingletonClass()); obj.getSingletonClass().addMethod(methodName.asJavaString(), m); if (obj instanceof RubyModule) { ((RubyModule) obj).addMethod(methodName.asJavaString(), m); } getRuntime().getFFI().registerAttachedMethod(m, this); return this; } protected abstract DynamicMethod createDynamicMethod(RubyModule module);
/** * Attaches this function to a ruby module or class. * * @param module The module or class to attach the function to. * @param methodName The ruby name to attach the function as. */ @JRubyMethod(name="attach") public IRubyObject attach(ThreadContext context, IRubyObject obj, IRubyObject methodName) { DynamicMethod m = createDynamicMethod(obj.getSingletonClass()); obj.getSingletonClass().addMethod(methodName.asJavaString(), m); if (obj instanceof RubyModule) { ((RubyModule) obj).addMethod(methodName.asJavaString(), m); } getRuntime().getFFI().registerAttachedMethod(m, this); return this; } protected abstract DynamicMethod createDynamicMethod(RubyModule module);
/** * Attaches this function to a ruby module or class. * * @param module The module or class to attach the function to. * @param methodName The ruby name to attach the function as. */ @JRubyMethod(name="attach") public IRubyObject attach(ThreadContext context, IRubyObject obj, IRubyObject methodName) { DynamicMethod m = createDynamicMethod(obj.getSingletonClass()); m.setName(methodName.asJavaString()); obj.getSingletonClass().addMethod(methodName.asJavaString(), m); if (obj instanceof RubyModule) { ((RubyModule) obj).addMethod(methodName.asJavaString(), m); } getRuntime().getFFI().registerAttachedMethod(m, this); return this; } protected abstract DynamicMethod createDynamicMethod(RubyModule module);
/** * Attaches this function to a ruby module or class. * * @param module The module or class to attach the function to. * @param methodName The ruby name to attach the function as. */ @JRubyMethod(name="attach") public IRubyObject attach(ThreadContext context, IRubyObject obj, IRubyObject methodName) { DynamicMethod m = createDynamicMethod(obj.getSingletonClass()); m.setName(methodName.asJavaString()); obj.getSingletonClass().addMethod(methodName.asJavaString(), m); if (obj instanceof RubyModule) { ((RubyModule) obj).addMethod(methodName.asJavaString(), m); } getRuntime().getFFI().registerAttachedMethod(m, this); return this; } protected abstract DynamicMethod createDynamicMethod(RubyModule module);