module Diagnostics module Methods DIAGNOSTIC_MESSAGES = { :passed => 'All Systems Operational', :warning => 'Experiencing Issues', :failed => 'System Failure', :none => 'No Diagnostic Checks Run' } def diagnostic_checks Diagnostics.checks end def diagnostic_check(name, &block) block ? Check.add(name, &block) : Check.find(name) end 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 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 private def diagnostic_statuses @diagnostic_statuses ||= diagnostic_checks.map(&:status).uniq end end end class Object include Diagnostics::Methods end