final Ruby runtime = ((JRubyConstructor)ctor).runtime;
if(theCls.respondsTo("yaml_new")) {
final RubyHash vars = (RubyHash)(((JRubyConstructor)ctor).constructRubyMapping(node));
return RuntimeHelpers.invoke(runtime.getCurrentContext(), theCls, "yaml_new", theCls, runtime.newString(node.getTag()), vars);
} else {
final RubyObject oo = (RubyObject)theCls.getAllocator().allocate(runtime, theCls);
if (oo.respondsTo("yaml_initialize")) {
RubyHash vars = (RubyHash)(((JRubyConstructor)ctor).constructRubyMapping(node));
RuntimeHelpers.invoke(runtime.getCurrentContext(), oo, "yaml_initialize", runtime.newString(node.getTag()), vars);
} else {
final Map vars = (Map)(ctor.constructMapping(node));
ctor.doRecursionFix(node, oo);
for(final Iterator iter = vars.keySet().iterator();iter.hasNext();) {
final IRubyObject key = (IRubyObject)iter.next();
final Object val = vars.get(key);
if(val instanceof LinkNode) {
final String KEY = "@" + key.toString();
ctor.addFixer((Node)(((LinkNode)val).getValue()), new RecursiveFixer() {
public void replace(Node node, Object real) {
oo.setInstanceVariable(KEY,(IRubyObject)real);
}
});
} else {
oo.setInstanceVariable("@" + key.toString(),(IRubyObject)val);
}
}
}
return oo;
}