Class: ServerStatus::Commands::Remove

Inherits:
BaseCommand show all
Defined in:
lib/server-status/commands/remove.rb

Instance Attribute Summary

Attributes inherited from BaseCommand

#config

Instance Method Summary collapse

Methods inherited from BaseCommand

#settings

Constructor Details

#initialize(config, name) ⇒ Remove

Returns a new instance of Remove.



4
5
6
7
# File 'lib/server-status/commands/remove.rb', line 4

def initialize(config, name)
  super(config)
  @name = name
end

Instance Method Details

#performObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/server-status/commands/remove.rb', line 9

def perform
  if settings['hosts'] && settings['hosts'][@name]
    settings['hosts'].delete(@name)
    config.save

    puts "Removed #{@name}"

    return
  end

  puts "#{@name} does not exist"
  exit(1)
end