class Realm::HealthStatus
Constants
- CODES
Attributes
code[R]
issues[R]
Public Class Methods
[](code, *issues)
click to toggle source
# File lib/realm/health_status.rb, line 9 def [](code, *issues) new(code, issues.flatten) end
combine(component_map)
click to toggle source
# File lib/realm/health_status.rb, line 17 def combine(component_map) code_index = component_map.values.map { |i| CODES.index(i.code) }.max new(CODES[code_index || 0], [], component_map) end
from_issues(issues)
click to toggle source
# File lib/realm/health_status.rb, line 13 def from_issues(issues) new(issues.blank? ? :green : :red, issues) end
new(code, issues = [], component_map = {})
click to toggle source
# File lib/realm/health_status.rb, line 36 def initialize(code, issues = [], component_map = {}) raise ArgumentError, "Invalid status code #{code}" unless CODES.include?(code) @code = code @issues = issues.freeze @component_map = component_map.freeze end
Public Instance Methods
for_component(*names)
click to toggle source
# File lib/realm/health_status.rb, line 23 def for_component(*names) @component_map.dig(*names) end
to_h()
click to toggle source
# File lib/realm/health_status.rb, line 27 def to_h hash = { status: @code } hash[:issues] = @issues if @issues.present? hash[:components] = @component_map.transform_values(&:to_h) if @component_map.present? hash end