Sha256: a3b5efc2468698ac3301ad57b923120eda9a084f6bb8ee4201c24b17ef56426f

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

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

class InvokeInstanceMethodHandler extends AbstractHandler {
    constructor() {
        super()
    }

    requiredParametersCount = 2

    process(command) {
        try {
            if (command.payload.length < this.requiredParametersCount) {
                throw new Error("Invoke Instance Method parameters mismatch")
            }
            const {payload} = command
            let instance = payload[0]
            let methodName = payload[1]
            let args = payload.slice(2)
            let method = instance[methodName]
            if (typeof(method) === 'undefined') {
                throw new Error("Instance method does not exist")
            } else {
                return Reflect.apply(instance[methodName], undefined, args)
            }

        }
        catch (error){
            throw this.process_stack_trace(error, this.constructor.name)
        }
    }
}

module.exports = new InvokeInstanceMethodHandler()

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
javonet-ruby-sdk-2.1.10 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/InvokeInstanceMethodHandler.js
javonet-ruby-sdk-2.1.9 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/InvokeInstanceMethodHandler.js
javonet-ruby-sdk-2.1.8 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/InvokeInstanceMethodHandler.js