Sha256: 5c250c7f93be313b084170be54eaed4c2aceeb552bba02b01039df07c6f16492

Contents?: true

Size: 896 Bytes

Versions: 6

Compression:

Stored size: 896 Bytes

Contents

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

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

    requiredParametersCount = 1

    process(command) {
        try {
            if (command.payload.length < this.requiredParametersCount) {
                throw new Error("Create Class Instance parameters mismatch")
            }
            let clazz = command.payload[0]
            let constructorArguments = command.payload.slice(1)
            let instance = new clazz(...constructorArguments)
            if (typeof(instance) == 'undefined') {
                throw "Instance cannot be created"
            } else {
                return instance
            }
        } catch (error) {
            throw this.process_stack_trace(error, this.constructor.name)
        }
    }
}

module.exports = new CreateClassInstanceHandler()

Version data entries

6 entries across 3 versions & 1 rubygems

Version Path
javonet-ruby-sdk-2.1.10 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/handler/CreateClassInstanceHandler.js
javonet-ruby-sdk-2.1.10 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/CreateClassInstanceHandler.js
javonet-ruby-sdk-2.1.9 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/handler/CreateClassInstanceHandler.js
javonet-ruby-sdk-2.1.9 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/CreateClassInstanceHandler.js
javonet-ruby-sdk-2.1.8 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/handler/CreateClassInstanceHandler.js
javonet-ruby-sdk-2.1.8 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/handler/CreateClassInstanceHandler.js