@JRubyMethod(name = "initialize", required = 1) public IRubyObject initialize(ThreadContext context, IRubyObject options) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { if (getProcessor() != null) { // Instance was created in Java and has options set, so we pass these // instead of those passed by asciidoctor Helpers.invokeSuper( context, this, getMetaClass(), METHOD_NAME_INITIALIZE, new IRubyObject[]{ RubyHashUtil.convertMapToRubyHashWithSymbols(getRuntime(), getProcessor().getConfig())}, Block.NULL_BLOCK); // The extension config in the Java extension is just a view on the @config member of the Ruby part getProcessor().updateConfig(new RubyHashMapDecorator((RubyHash) getInstanceVariable(MEMBER_NAME_CONFIG))); } else { // First create only the instance passing in the block name setProcessor(instantiateProcessor(new HashMap<String, Object>())); // Then create the config hash that may contain config options defined in the Java constructor RubyHash config = RubyHashUtil.convertMapToRubyHashWithSymbols(context.getRuntime(), getProcessor().getConfig()); // Initialize the Ruby part and pass in the config options Helpers.invokeSuper(context, this, getMetaClass(), METHOD_NAME_INITIALIZE, new IRubyObject[] {config}, Block.NULL_BLOCK); // Reset the Java config options to the decorated Ruby hash, so that Java and Ruby work on the same config map getProcessor().setConfig(new RubyHashMapDecorator((RubyHash) getInstanceVariable(MEMBER_NAME_CONFIG))); } finalizeJavaConfig(); return null; }
@JRubyMethod(name = "initialize", required = 1) public IRubyObject initialize(ThreadContext context, IRubyObject options) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { if (getProcessor() != null) { // Instance was created in Java and has options set, so we pass these // instead of those passed by asciidoctor Helpers.invokeSuper( context, this, getMetaClass(), METHOD_NAME_INITIALIZE, new IRubyObject[]{ RubyHashUtil.convertMapToRubyHashWithSymbols(getRuntime(), getProcessor().getConfig())}, Block.NULL_BLOCK); // The extension config in the Java extension is just a view on the @config member of the Ruby part getProcessor().updateConfig(new RubyHashMapDecorator((RubyHash) getInstanceVariable(MEMBER_NAME_CONFIG))); } else { // First create only the instance passing in the block name setProcessor(instantiateProcessor(new HashMap<String, Object>())); // Then create the config hash that may contain config options defined in the Java constructor RubyHash config = RubyHashUtil.convertMapToRubyHashWithSymbols(context.getRuntime(), getProcessor().getConfig()); // Initialize the Ruby part and pass in the config options Helpers.invokeSuper(context, this, getMetaClass(), METHOD_NAME_INITIALIZE, new IRubyObject[] {config}, Block.NULL_BLOCK); // Reset the Java config options to the decorated Ruby hash, so that Java and Ruby work on the same config map getProcessor().setConfig(new RubyHashMapDecorator((RubyHash) getInstanceVariable(MEMBER_NAME_CONFIG))); } finalizeJavaConfig(); return null; }