Class: SolidObjects::Doctor::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/solid_objects/doctor.rb,
sig/generated/lib/solid_objects/doctor.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(checks:) ⇒ Report

Returns a new instance of Report.

RBS:

  • (checks: Array[Check]) -> void

Parameters:



35
36
37
38
# File 'lib/solid_objects/doctor.rb', line 35

def initialize(checks:)
  @checks = checks.freeze
  freeze
end

Instance Attribute Details

#checksObject (readonly)

RBS:

  • @checks: Array[Check]

Returns:

  • (Object)


32
33
34
# File 'lib/solid_objects/doctor.rb', line 32

def checks
  @checks
end

Instance Method Details

#check(name) ⇒ Check

RBS:

  • (Symbol) -> Check

Parameters:

  • (Symbol)

Returns:



46
47
48
49
# File 'lib/solid_objects/doctor.rb', line 46

def check(name)
  checks.find { |candidate| candidate.name == name } ||
    raise(KeyError, "unknown doctor check #{name.inspect}")
end

#healthy?Boolean

RBS:

  • () -> bool

Returns:

  • (Boolean)


41
42
43
# File 'lib/solid_objects/doctor.rb', line 41

def healthy?
  checks.none?(&:failed?)
end

#to_sString

RBS:

  • () -> String

Returns:

  • (String)


52
53
54
55
56
57
58
59
60
# File 'lib/solid_objects/doctor.rb', line 52

def to_s
  lines = [ "Solid Objects doctor #{SolidObjects::VERSION}" ]
  lines.concat(
    checks.map do |check|
      "#{check.status.to_s.upcase.ljust(4)} #{check.name}: #{check.message}"
    end
  )
  lines.join("\n")
end