Class: Igniter::Contracts::Execution::DiagnosticsReport

Inherits:
Object
  • Object
show all
Defined in:
lib/igniter/contracts/execution/diagnostics_report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDiagnosticsReport

Returns a new instance of DiagnosticsReport.



9
10
11
# File 'lib/igniter/contracts/execution/diagnostics_report.rb', line 9

def initialize
  @sections = {}
end

Instance Attribute Details

#sectionsObject (readonly)

Returns the value of attribute sections.



7
8
9
# File 'lib/igniter/contracts/execution/diagnostics_report.rb', line 7

def sections
  @sections
end

Instance Method Details

#add_section(name, value) ⇒ Object



13
14
15
16
17
# File 'lib/igniter/contracts/execution/diagnostics_report.rb', line 13

def add_section(name, value)
  section = DiagnosticsSection.new(name: name, value: value)
  sections[section.name] = section
  section
end

#section(name) ⇒ Object



19
20
21
22
# File 'lib/igniter/contracts/execution/diagnostics_report.rb', line 19

def section(name)
  value = section_object(name).value
  value.is_a?(NamedValues) ? value.to_h : value
end

#section_namesObject



28
29
30
# File 'lib/igniter/contracts/execution/diagnostics_report.rb', line 28

def section_names
  sections.keys
end

#section_object(name) ⇒ Object



24
25
26
# File 'lib/igniter/contracts/execution/diagnostics_report.rb', line 24

def section_object(name)
  sections.fetch(name.to_sym)
end

#to_hObject



32
33
34
35
36
# File 'lib/igniter/contracts/execution/diagnostics_report.rb', line 32

def to_h
  {
    sections: sections.transform_values(&:to_h)
  }
end