Sha256: a5b1d7ae355c40e246a6ea2e35048154391b205b3fb583a04f218be4754e8c1a

Contents?: true

Size: 1.25 KB

Versions: 31

Compression:

Stored size: 1.25 KB

Contents

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

class SetGlobalStaticFieldHandler extends AbstractHandler {
  requiredParametersCount = 2;

  constructor() {
    super();
  }

  process(command) {
    try {
      if (command.payload.length < this.requiredParametersCount) {
        throw new Error("Set gloabal static field parameters mismatch");
      }
      const { payload } = command;
      const splitted = payload[0].split(".");
      const value = payload[1];
      let fieldToSet;

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

module.exports = new SetGlobalStaticFieldHandler();

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/SetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.5.6 lib/javonet-ruby-sdk/Binaries/Nodejs/core/handler/SetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.5.5 lib/javonet-ruby-sdk/Binaries/Nodejs/core/handler/SetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.5.4 lib/javonet-ruby-sdk/Binaries/Nodejs/core/handler/SetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.5.3 lib/javonet-ruby-sdk/Binaries/Nodejs/core/handler/SetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.5.2 lib/javonet-ruby-sdk/Binaries/Nodejs/core/handler/SetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.5.1 lib/javonet-ruby-sdk/Binaries/Nodejs/core/handler/SetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.5.0 lib/javonet-ruby-sdk/Binaries/Nodejs/core/handler/SetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.4.11 lib/javonet-ruby-sdk/Binaries/Nodejs/core/handler/SetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.4.10 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/SetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.4.10 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/handler/SetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.4.9 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/handler/SetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.4.9 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/SetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.4.8 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/handler/SetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.4.8 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/SetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.4.7 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/SetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.4.7 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/handler/SetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.4.6 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/SetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.4.6 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/handler/SetGlobalStaticFieldHandler.js
javonet-ruby-sdk-2.4.5 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/SetGlobalStaticFieldHandler.js