Class: Daemon::Utils::CommandsServer::Commands

Inherits:
Object
  • Object
show all
Defined in:
lib/onapp/engine/utils/commands_server/commands.rb

Instance Method Summary (collapse)

Constructor Details

- (Commands) initialize

Returns a new instance of Commands



5
6
7
# File 'lib/onapp/engine/utils/commands_server/commands.rb', line 5

def initialize
  @hash = {}
end

Instance Method Details

- (Object) call(cmd)



17
18
19
# File 'lib/onapp/engine/utils/commands_server/commands.rb', line 17

def call(cmd)
  @hash[normalize_cmd(cmd)].call
end

- (Boolean) exists?(cmd)

Returns:

  • (Boolean)


13
14
15
# File 'lib/onapp/engine/utils/commands_server/commands.rb', line 13

def exists?(cmd)
  @hash[normalize_cmd(cmd)].respond_to?(:call)
end

- (Object) on(cmd, &block)



9
10
11
# File 'lib/onapp/engine/utils/commands_server/commands.rb', line 9

def on(cmd, &block)
  @hash[normalize_cmd(cmd)] = block if block
end