Module: Diagnostics::Methods

Included in:
Object
Defined in:
lib/diagnostics/methods.rb

Constant Summary collapse

DIAGNOSTIC_MESSAGES =
{
  :passed  => 'All Systems Operational',
  :warning => 'Experiencing Issues',
  :failed  => 'System Failure',
  :none    => 'No Diagnostic Checks Run'
}

Instance Method Summary collapse

Instance Method Details

#diagnostic_check(name) ⇒ Object



15
16
17
# File 'lib/diagnostics/methods.rb', line 15

def diagnostic_check(name)
  Check.find(name)
end

#diagnostic_checksObject



11
12
13
# File 'lib/diagnostics/methods.rb', line 11

def diagnostic_checks
  Diagnostics.checks
end

#diagnostic_messageObject



19
20
21
22
23
24
25
26
# File 'lib/diagnostics/methods.rb', line 19

def diagnostic_message
  case diagnostic_status
    when :passed  then DIAGNOSTIC_MESSAGES[:passed]
    when :warning then DIAGNOSTIC_MESSAGES[:warning]
    when :failed  then DIAGNOSTIC_MESSAGES[:failed]
    when :none    then DIAGNOSTIC_MESSAGES[:none]
  end
end

#diagnostic_statusObject



28
29
30
31
32
33
# File 'lib/diagnostics/methods.rb', line 28

def diagnostic_status
  return :failed  if diagnostic_statuses.include?(:failed)
  return :warning if diagnostic_statuses.include?(:warning)
  return :passed  if diagnostic_statuses.include?(:passed)
  :none
end