Module: RosettAi::Doctor::Check

Overview

Base interface for diagnostic checks.

Include this module and implement #perform to create a check. The #run method calls #perform and sets status/message/remediation.

Author:

  • hugo

  • claude

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#messageString (readonly)

Returns result description.

Returns:

  • (String)

    result description



25
26
27
# File 'lib/rosett_ai/doctor/check.rb', line 25

def message
  @message
end

#remediationString? (readonly)

Returns remediation steps (nil when passing).

Returns:

  • (String, nil)

    remediation steps (nil when passing)



28
29
30
# File 'lib/rosett_ai/doctor/check.rb', line 28

def remediation
  @remediation
end

#statusSymbol (readonly)

Returns :pass, :warn, or :fail.

Returns:

  • (Symbol)

    :pass, :warn, or :fail



22
23
24
# File 'lib/rosett_ai/doctor/check.rb', line 22

def status
  @status
end

Class Method Details

.included(base) ⇒ Object

Register this check class with the Doctor module.

Parameters:

  • check_name (String)

    unique check identifier



40
41
42
# File 'lib/rosett_ai/doctor/check.rb', line 40

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#nameString

Returns human-readable check name.

Returns:

  • (String)

    human-readable check name



17
18
19
# File 'lib/rosett_ai/doctor/check.rb', line 17

def name
  self.class.check_name
end

#run

This method returns an undefined value.

Execute the check. Sets status, message, and remediation.



32
33
34
35
36
# File 'lib/rosett_ai/doctor/check.rb', line 32

def run
  perform
rescue StandardError => e
  fail!(e.message, remediation: ::I18n.t('rosett_ai.doctor.unexpected_error'))
end