Class: Ruby::Nginx::Commands::RemoveHostMapping
- Inherits:
-
TerminalCommand
- Object
- TerminalCommand
- Ruby::Nginx::Commands::RemoveHostMapping
- Defined in:
- lib/ruby/nginx/commands/remove_host_mapping.rb
Instance Attribute Summary
Attributes inherited from TerminalCommand
#cmd, #error_type, #printer, #result, #user
Instance Method Summary collapse
-
#initialize(host, ignore_ip: nil, sudo: false) ⇒ RemoveHostMapping
constructor
A new instance of RemoveHostMapping.
- #run ⇒ Object
Methods included from Helpers::SudoHelper
Methods included from Helpers::PromptHelper
Constructor Details
#initialize(host, ignore_ip: nil, sudo: false) ⇒ RemoveHostMapping
Returns a new instance of RemoveHostMapping.
10 11 12 13 14 15 16 17 |
# File 'lib/ruby/nginx/commands/remove_host_mapping.rb', line 10 def initialize(host, ignore_ip: nil, sudo: false) @host = host @ignore_ip = ignore_ip @sudo = sudo @sudo_reason = "Allow sudo elevation to remove \"#{host}\" from /etc/hosts?" super(cmd: resolve_command, raise: Ruby::Nginx::ConfigError) end |
Instance Method Details
#run ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/ruby/nginx/commands/remove_host_mapping.rb', line 19 def run super unless removed? rescue Ruby::Nginx::ConfigError raise if @sudo # Elevate to sudo and try again. self.class.new(@host, ignore_ip: @ignore_ip, sudo: true).run end |