Module: Ruby::Nginx::Commands::Helpers::SudoHelper

Includes:
PromptHelper
Included in:
TerminalCommand
Defined in:
lib/ruby/nginx/commands/helpers/sudo_helper.rb

Instance Method Summary collapse

Methods included from PromptHelper

#yes?

Instance Method Details

#sudoify(cmd, sudo, reason) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/ruby/nginx/commands/helpers/sudo_helper.rb', line 13

def sudoify(cmd, sudo, reason)
  return cmd unless sudo

  if sudo_access? || yes?(reason)
    "sudo #{cmd}"
  else
    raise Ruby::Nginx::AbortError, "Operation aborted"
  end
end