Sha256: 7f3d6b5def77209b9d0e1c5f99aadbb91cf1c3ea5db6545bad00b2167a21d1eb

Contents?: true

Size: 938 Bytes

Versions: 31

Compression:

Stored size: 938 Bytes

Contents

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

class SetStaticFieldHandler extends AbstractHandler {
  requiredParametersCount = 3;

  constructor() {
    super();
  }

  process(command) {
    try {
      if (command.payload.length < this.requiredParametersCount) {
        throw new Error("Set static field parameters mismatch");
      }
      const { payload } = command;
      let [obj, field, value] = payload;
      if (typeof obj[field] === "undefined") {
        let fields = Object.keys(obj);
        let message = `Field ${field} not found in class ${obj.constructor.name}. Available fields:\n`;
        fields.forEach((fieldIter) => {
          message += `${fieldIter}\n`;
        });
        throw new Error(message);
      }
      obj[field] = value;
      return 0;
    } catch (error) {
      throw this.process_stack_trace(error, this.constructor.name);
    }
  }
}

module.exports = new SetStaticFieldHandler();

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