Sha256: f1e9569c46eb78cf3b31d83896e1eb2efcdfd6dd489376095bfccbe97518e899

Contents?: true

Size: 1.14 KB

Versions: 11

Compression:

Stored size: 1.14 KB

Contents

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

class GetGlobalStaticFieldHandler extends AbstractHandler {
  requiredParametersCount = 1;

  constructor() {
    super();
  }

  process(command) {
    try {
      if (command.payload.length < this.requiredParametersCount) {
        throw new Error("Get global static field parameters mismatch");
      }
      const { payload } = command;
      const splitted = payload[0].split(".");
      let fieldToGet;

      for (let i = 0; i < splitted.length; i++) {
        fieldToGet = !fieldToGet
          ? global[splitted[i]]
          : fieldToGet[splitted[i]];
        if (typeof fieldToGet === "undefined") {
          let fields = Object.keys(global);
          let message = `Field ${payload[0]} not found in global. Available fields:\n`;
          fields.forEach((fieldIter) => {
            message += `${fieldIter}\n`;
          });
          throw new Error(message);
        }
      }
      return fieldToGet;
    } catch (error) {
      throw this.process_stack_trace(error, this.constructor.name);
    }
  }
}

module.exports = new GetGlobalStaticFieldHandler();

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
javonet-ruby-sdk-2.4.10 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/GetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.4.9 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/GetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.4.8 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/GetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.4.7 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/GetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.4.6 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/GetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.4.5 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/GetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.4.4 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/GetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.4.3 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/GetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.4.2 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/GetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.3.0 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/GetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.2.0 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/GetGlobalStaticFieldHandler.js