Sha256: 62bbc3f730e74a638b52c93af48b279c3800a860c2ffd91aabdc0519ed5d8e70

Contents?: true

Size: 988 Bytes

Versions: 32

Compression:

Stored size: 988 Bytes

Contents

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

class SetInstanceFieldHandler extends AbstractHandler {
  requiredParametersCount = 3;

  constructor() {
    super();
  }

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

module.exports = new SetInstanceFieldHandler();

Version data entries

32 entries across 21 versions & 1 rubygems

Version Path
javonet-ruby-sdk-2.4.5 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/handler/SetInstanceFieldHandler.js
javonet-ruby-sdk-2.4.5 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/SetInstanceFieldHandler.js
javonet-ruby-sdk-2.4.4 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/handler/SetInstanceFieldHandler.js
javonet-ruby-sdk-2.4.4 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/SetInstanceFieldHandler.js
javonet-ruby-sdk-2.4.3 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/SetInstanceFieldHandler.js
javonet-ruby-sdk-2.4.3 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/handler/SetInstanceFieldHandler.js
javonet-ruby-sdk-2.4.2 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/SetInstanceFieldHandler.js
javonet-ruby-sdk-2.4.2 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/handler/SetInstanceFieldHandler.js
javonet-ruby-sdk-2.3.0 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/handler/SetInstanceFieldHandler.js
javonet-ruby-sdk-2.3.0 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/SetInstanceFieldHandler.js
javonet-ruby-sdk-2.2.0 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/SetInstanceFieldHandler.js
javonet-ruby-sdk-2.2.0 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/handler/SetInstanceFieldHandler.js