Class List Method List File List

# Class: VertxShell::CommandRegistry

Inherits:
  CommandResolver
  - Object
  - CommandResolver
  - VertxShell::CommandRegistry
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_registry.rb

## Overview

A registry that contains the commands known by a shell.

It is a mutable command resolver.

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (::VertxShell::CommandRegistry) create(vertx = nil)
  Create a new registry.
- + (::VertxShell::CommandRegistry) get_shared(vertx = nil)
  Get the shared registry for the Vert.x instance.
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (Array<::VertxShell::Command>) commands
  The current commands.
- - (::VertxShell::Command) get_command(name = nil)
  Returns a single command by its name.
- - (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

## Class Method Details

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

    23
    24
    25
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_registry.rb', line 23

    def @@j_api_type.accept?(obj)
      obj.class == CommandRegistry
    end

### + (`::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`)

    66
    67
    68
    69
    70
    71
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_registry.rb', line 66

    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`)

    57
    58
    59
    60
    61
    62
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_registry.rb', line 57

    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

### + (`Object`) j_api_type

    32
    33
    34
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_registry.rb', line 32

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

    35
    36
    37
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_registry.rb', line 35

    def self.j_class
      Java::IoVertxExtShellCommand::CommandRegistry.java_class
    end

### + (`Object`) unwrap(obj)

    29
    30
    31
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_registry.rb', line 29

    def @@j_api_type.unwrap(obj)
      obj.j_del
    end

### + (`Object`) wrap(obj)

    26
    27
    28
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_registry.rb', line 26

    def @@j_api_type.wrap(obj)
      CommandRegistry.new(obj)
    end

## Instance Method Details

### - (`Array<::VertxShell::Command>`) commands

Returns the current commands

Returns:

- (`Array<::VertxShell::Command>`) —
  the current commands

Raises:

- (`ArgumentError`)

    39
    40
    41
    42
    43
    44
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_registry.rb', line 39

    def commands
      if !block_given?
        return @j_del.java_method(:commands, []).call().to_a.map { |elt| ::Vertx::Util::Utils.safe_create(elt,::VertxShell::Command) }
      end
      raise ArgumentError, "Invalid arguments when calling commands()"
    end

### - (`::VertxShell::Command`) get_command(name = nil)

Returns a single command by its name.

Parameters:

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

Returns:

- (`::VertxShell::Command`) —
  the commad or null

Raises:

- (`ArgumentError`)

    48
    49
    50
    51
    52
    53
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_registry.rb', line 48

    def get_command(name=nil)
      if name.class == String && !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:getCommand, [Java::java.lang.String.java_class]).call(name),::VertxShell::Command)
      end
      raise ArgumentError, "Invalid arguments when calling get_command(#{name})"
    end

### - (`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`)

    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_registry.rb', line 76

    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`)

    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_registry.rb', line 90

    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`)

    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_registry.rb', line 104

    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