class StatusCheck::Services::Abstract

Attributes

connection[R]

Public Class Methods

new(connection) click to toggle source
# File lib/status_check/services/abstract.rb, line 6
def initialize(connection)
  @connection = connection
end

Public Instance Methods

command() click to toggle source
# File lib/status_check/services/abstract.rb, line 10
def command
  raise NotImplementedError, "Check command have to be defined"
end
report_status() click to toggle source
# File lib/status_check/services/abstract.rb, line 20
def report_status
  command_result = command
  status_hash(command_result)
rescue StandardError => exception
  status_hash(command_result, exception)
end
status_message(command_result, exception = nil) click to toggle source
# File lib/status_check/services/abstract.rb, line 14
def status_message(command_result, exception = nil)
  return exception.to_s if !command_result && exception
  return 'FAILED' if !command_result
  'OK'
end

Private Instance Methods

status_hash(command_result, exception = nil) click to toggle source
# File lib/status_check/services/abstract.rb, line 29
def status_hash(command_result, exception = nil)
  [!!command_result, status_message(command_result, exception)]
end