if (!self.getMetaClass().searchMethod(methodName).isUndefined()) {
return (RubyMethod) ((RubyObject) self).method(name);
}
// try to get method from delegated object
final RubyMethod method = (RubyMethod) ((RubyObject) object).method(name);
return RubyMethod.newMethod(self.getMetaClass(), methodName, self.getMetaClass(), methodName, new JavaMethodNBlock(self.getMetaClass(), Visibility.PUBLIC) {
@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
if (self.callMethod(context, "__getobj__") != object) {
throw context.runtime.newNameError("object changed", "object changed");