@JRubyMethod(name = "method_missing", rest = true)
public IRubyObject methodMissing(ThreadContext context, IRubyObject[] args) {
if (args.length == 1) {
RubyDescriptor rubyDescriptor = (RubyDescriptor) getDescriptor(context, metaClass);
IRubyObject oneofDescriptor = rubyDescriptor.lookupOneof(context, args[0]);
if (oneofDescriptor.isNil()) {
if (!hasField(args[0])) {
return Helpers.invokeSuper(context, this, metaClass, "method_missing", args, Block.NULL_BLOCK);
}
return index(context, args[0]);
}
RubyOneofDescriptor rubyOneofDescriptor = (RubyOneofDescriptor) oneofDescriptor;
Descriptors.FieldDescriptor fieldDescriptor =
oneofCases.get(rubyOneofDescriptor.getOneofDescriptor());
if (fieldDescriptor == null)
return context.runtime.getNil();
return context.runtime.newSymbol(fieldDescriptor.getName());
} else {
RubyString field = args[0].asString();
RubyString equalSign = context.runtime.newString(Utils.EQUAL_SIGN);
if (field.end_with_p(context, equalSign).isTrue()) {
field.chomp_bang(context, equalSign);
}
if (!hasField(field)) {
return Helpers.invokeSuper(context, this, metaClass, "method_missing", args, Block.NULL_BLOCK);
}
return indexSet(context, field, args[1]);
}
}