Class List Method List File List

# Class: VertxShell::CommandRegistry

Inherits:
  CommandResolver
  - Object
  - CommandResolver
  - VertxShell::CommandRegistry
  show all
Defined in:
  /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/command_registry.rb

## Overview

A registry that contains the commands known by a shell.

It is a mutable command resolver.

## Class Method Summary (collapse)

- + (::VertxShell::CommandRegistry) create(vertx = nil)
  Create a new registry.
- + (::VertxShell::CommandRegistry) get_shared(vertx = nil)
  Get the shared registry for the Vert.x instance.

## Instance Method Summary (collapse)

- - (self) register_command(command = nil) { ... }
  Register a command.
- - (self) register_commands(commands = nil) { ... }
  Register a list of commands.
- - (self) unregister_command(commandName = nil) { ... }
  Unregister a command.

### Methods inherited from CommandResolver

base_commands, #commands, #get_command

## Class Method Details

### + (`::VertxShell::CommandRegistry`) create(vertx = nil)

Create a new registry.

Parameters:

- vertx (`::Vertx::Vertx`) (defaults to: `nil`) —
  the vertx instance

Returns:

- (`::VertxShell::CommandRegistry`) —
  the created registry

Raises:

- (`ArgumentError`)

    34
    35
    36
    37
    38
    39
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/command_registry.rb', line 34

    def self.create(vertx=nil)
      if vertx.class.method_defined?(:j_del) && !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtShellCommand::CommandRegistry.java_method(:create, [Java::IoVertxCore::Vertx.java_class]).call(vertx.j_del),::VertxShell::CommandRegistry)
      end
      raise ArgumentError, "Invalid arguments when calling create(vertx)"
    end

### + (`::VertxShell::CommandRegistry`) get_shared(vertx = nil)

Get the shared registry for the Vert.x instance.

Parameters:

- vertx (`::Vertx::Vertx`) (defaults to: `nil`) —
  the vertx instance

Returns:

- (`::VertxShell::CommandRegistry`) —
  the shared registry

Raises:

- (`ArgumentError`)

    25
    26
    27
    28
    29
    30
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/command_registry.rb', line 25

    def self.get_shared(vertx=nil)
      if vertx.class.method_defined?(:j_del) && !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtShellCommand::CommandRegistry.java_method(:getShared, [Java::IoVertxCore::Vertx.java_class]).call(vertx.j_del),::VertxShell::CommandRegistry)
      end
      raise ArgumentError, "Invalid arguments when calling get_shared(vertx)"
    end

## Instance Method Details

### - (`self`) register_command(command = nil) { ... }

Register a command

Parameters:

- command (`::VertxShell::Command`) (defaults to: `nil`) —
  the command to register

Yields:

- notified when the command is registered

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/command_registry.rb', line 44

    def register_command(command=nil)
      if command.class.method_defined?(:j_del) && !block_given?
        @j_del.java_method(:registerCommand, [Java::IoVertxExtShellCommand::Command.java_class]).call(command.j_del)
        return self
      elsif command.class.method_defined?(:j_del) && block_given?
        @j_del.java_method(:registerCommand, [Java::IoVertxExtShellCommand::Command.java_class,Java::IoVertxCore::Handler.java_class]).call(command.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxShell::Command) : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling register_command(command)"
    end

### - (`self`) register_commands(commands = nil) { ... }

Register a list of commands.

Parameters:

- commands (`Array<::VertxShell::Command>`) (defaults to: `nil`) —
  the commands to register

Yields:

- notified when the command is registered

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/command_registry.rb', line 58

    def register_commands(commands=nil)
      if commands.class == Array && !block_given?
        @j_del.java_method(:registerCommands, [Java::JavaUtil::List.java_class]).call(commands.map { |element| element.j_del })
        return self
      elsif commands.class == Array && block_given?
        @j_del.java_method(:registerCommands, [Java::JavaUtil::List.java_class,Java::IoVertxCore::Handler.java_class]).call(commands.map { |element| element.j_del },(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result.to_a.map { |elt| ::Vertx::Util::Utils.safe_create(elt,::VertxShell::Command) } : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling register_commands(commands)"
    end

### - (`self`) unregister_command(commandName = nil) { ... }

Unregister a command.

Parameters:

- commandName (`String`) (defaults to: `nil`) —
  the command name

Yields:

- notified when the command is unregistered

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/command_registry.rb', line 72

    def unregister_command(commandName=nil)
      if commandName.class == String && !block_given?
        @j_del.java_method(:unregisterCommand, [Java::java.lang.String.java_class]).call(commandName)
        return self
      elsif commandName.class == String && block_given?
        @j_del.java_method(:unregisterCommand, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(commandName,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling unregister_command(commandName)"
    end