Skip to content

Commit

Permalink
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion core/src/main/java/org/jruby/runtime/Helpers.java
Original file line number Diff line number Diff line change
@@ -1859,7 +1859,20 @@ public static RubyArray arrayValue(ThreadContext context, Ruby runtime, IRubyObj
}
return (RubyArray)avalue;
} else {
return runtime.newArray(value);
DynamicMethod methodMissing = value.getMetaClass().searchMethod("method_missing");
if (methodMissing.isUndefined() || methodMissing.equals(runtime.getDefaultMethodMissing())) {
return runtime.newArray(value);
} else {
IRubyObject avalue = methodMissing.call(context, value, value.getMetaClass(), "to_a", new IRubyObject[] {runtime.newSymbol("to_a")}, Block.NULL_BLOCK);
if (!(avalue instanceof RubyArray)) {
if (avalue.isNil()) {
return runtime.newArray(value);
} else {
throw runtime.newTypeError("`to_a' did not return Array");
}
}
return (RubyArray)avalue;
}
}
}
RubyArray arr = (RubyArray) tmp;

0 comments on commit fda9948

Please sign in to comment.