These are chat archives for opal/opal

16th
Jun 2018
Guillaume Grossetie
@Mogztter
Jun 16 2018 13:59
Hello, I'm trying to extend a class using the JavaScript API on master branch
I did update this code to use Opal.def instead of Opal.defn
Guillaume Grossetie
@Mogztter
Jun 16 2018 14:05
module.exports = (function (Opal) {
  var includeProcessor = Opal.const_get_qualified(Opal.const_get_qualified(Opal.const_get_relative(Opal, 'Asciidoctor'), 'Extensions'), 'IncludeProcessor');
  var scope = Opal.klass(null, includeProcessor, 'LoremIncludeProcessor', function () {});

  Opal.def(scope, '$process', function (doc, reader, target, attrs) {
    return reader.$push_include('Lorem ipsum', target, target, 1, attrs);
  });

  return scope;
})(Opal);
But I get the following exception:
  Message:
    TypeError: block.apply is not a function
  Stack:
        at <Jasmine>
        at $IncludeProcessor.$$instance_exec (/home/guillaume/workspace/opensource/opal/opal-node-runtime/src/opal.js:3771:24)
        at Opal.send (/home/guillaume/workspace/opensource/opal/opal-node-runtime/src/opal.js:1646:19)
        at /home/guillaume/workspace/opensource/asciidoctor/asciidoctor.js/build/asciidoctor-node.js:17034:13
        at $Registry.$$add_document_processor (/home/guillaume/workspace/opensource/asciidoctor/asciidoctor.js/build/asciidoctor-node.js:17061:28)
        at Opal.send (/home/guillaume/workspace/opensource/opal/opal-node-runtime/src/opal.js:1646:19)
        at $Registry.$$include_processor (/home/guillaume/workspace/opensource/asciidoctor/asciidoctor.js/build/asciidoctor-node.js:16829:18)
        at Object.Opal.send (/home/guillaume/workspace/opensource/opal/opal-node-runtime/src/opal.js:1646:19)
        at registerExtension (/home/guillaume/workspace/opensource/asciidoctor/asciidoctor.js/build/asciidoctor-node.js:19565:17)
And here's the code generated by Opal, not sure what I'm missing:
(function($base, $super, $parent_nesting) {
    function $LoremIncludeProcessor(){};
    var self = $LoremIncludeProcessor = $klass($base, $super, 'LoremIncludeProcessor', $LoremIncludeProcessor);

    var def = self.prototype, $nesting = [self].concat($parent_nesting), TMP_LoremIncludeProcessor_process_1;

    return (Opal.def(self, '$process', TMP_LoremIncludeProcessorr_process_1 = function $$process(doc, reader, target, attributes) {
      var self = this;

      return reader.$push_include("Lorem ipsum", self.$target(), self.$target(), 1, attributes)
    }, TMP_LoremIncludeProcessor_process_1.$$arity = 4), nil) && 'process'
  })($nesting[0], $$$($$$($$($nesting, 'Asciidoctor'), 'Extensions'), 'IncludeProcessor'), $nesting);