Sha256: 8787c7771c108ca8d9ff4e07033f39109849feca29817a9b505667e93c66f9d1

Contents?: true

Size: 1.16 KB

Versions: 31

Compression:

Stored size: 1.16 KB

Contents

const AbstractHandler = require("./AbstractHandler");

class InvokeStaticMethodHandler extends AbstractHandler {
  requiredParametersCount = 2;

  constructor() {
    super();
  }

  process(command) {
    try {
      if (command.payload.length < this.requiredParametersCount) {
        throw new Error("Invoke Static Method parameters mismatch");
      }
      const { payload } = command;
      let type = payload[0];
      let methodName = payload[1];
      let args = payload.slice(2);
      let method = type[methodName];
      if (typeof method === "undefined") {
        let methods = Object.getOwnPropertyNames(type).filter(function (
          property
        ) {
          return typeof type[property] === "function";
        });
        let message = `Method ${methodName} not found in class. Available methods:\n`;
        methods.forEach((methodIter) => {
          message += `${methodIter}\n`;
        });
        throw new Error(message);
      } else {
        return Reflect.apply(method, undefined, args);
      }
    } catch (error) {
      throw this.process_stack_trace(error, this.constructor.name);
    }
  }
}

module.exports = new InvokeStaticMethodHandler();

Version data entries

31 entries across 20 versions & 1 rubygems

Version Path
javonet-ruby-sdk-2.5.7 lib/javonet-ruby-sdk/Binaries/Nodejs/core/handler/InvokeStaticMethodHandler.js
javonet-ruby-sdk-2.5.6 lib/javonet-ruby-sdk/Binaries/Nodejs/core/handler/InvokeStaticMethodHandler.js
javonet-ruby-sdk-2.5.5 lib/javonet-ruby-sdk/Binaries/Nodejs/core/handler/InvokeStaticMethodHandler.js
javonet-ruby-sdk-2.5.4 lib/javonet-ruby-sdk/Binaries/Nodejs/core/handler/InvokeStaticMethodHandler.js
javonet-ruby-sdk-2.5.3 lib/javonet-ruby-sdk/Binaries/Nodejs/core/handler/InvokeStaticMethodHandler.js
javonet-ruby-sdk-2.5.2 lib/javonet-ruby-sdk/Binaries/Nodejs/core/handler/InvokeStaticMethodHandler.js
javonet-ruby-sdk-2.5.1 lib/javonet-ruby-sdk/Binaries/Nodejs/core/handler/InvokeStaticMethodHandler.js
javonet-ruby-sdk-2.5.0 lib/javonet-ruby-sdk/Binaries/Nodejs/core/handler/InvokeStaticMethodHandler.js
javonet-ruby-sdk-2.4.11 lib/javonet-ruby-sdk/Binaries/Nodejs/core/handler/InvokeStaticMethodHandler.js
javonet-ruby-sdk-2.4.10 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/InvokeStaticMethodHandler.js
javonet-ruby-sdk-2.4.10 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/handler/InvokeStaticMethodHandler.js
javonet-ruby-sdk-2.4.9 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/handler/InvokeStaticMethodHandler.js
javonet-ruby-sdk-2.4.9 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/InvokeStaticMethodHandler.js
javonet-ruby-sdk-2.4.8 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/handler/InvokeStaticMethodHandler.js
javonet-ruby-sdk-2.4.8 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/InvokeStaticMethodHandler.js
javonet-ruby-sdk-2.4.7 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/InvokeStaticMethodHandler.js
javonet-ruby-sdk-2.4.7 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/handler/InvokeStaticMethodHandler.js
javonet-ruby-sdk-2.4.6 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/InvokeStaticMethodHandler.js
javonet-ruby-sdk-2.4.6 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/handler/InvokeStaticMethodHandler.js
javonet-ruby-sdk-2.4.5 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/InvokeStaticMethodHandler.js