Class: Ast::Merge::Runtime::Diagnostic

Inherits:
Object
  • Object
show all
Defined in:
lib/ast/merge/runtime/diagnostic.rb

Overview

Structured runtime event emitted during merge orchestration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(severity:, kind:, operation_id:, surface_path:, message:, metadata: {}) ⇒ Diagnostic

Returns a new instance of Diagnostic.



10
11
12
13
14
15
16
17
# File 'lib/ast/merge/runtime/diagnostic.rb', line 10

def initialize(severity:, kind:, operation_id:, surface_path:, message:, metadata: {})
  @severity = severity.to_sym
  @kind = kind.to_sym
  @operation_id = operation_id
  @surface_path = surface_path.to_s
  @message = message.to_s
  @metadata = .dup.freeze
end

Instance Attribute Details

#kindObject (readonly)

Returns the value of attribute kind.



8
9
10
# File 'lib/ast/merge/runtime/diagnostic.rb', line 8

def kind
  @kind
end

#messageObject (readonly)

Returns the value of attribute message.



8
9
10
# File 'lib/ast/merge/runtime/diagnostic.rb', line 8

def message
  @message
end

#metadataObject (readonly)

Returns the value of attribute metadata.



8
9
10
# File 'lib/ast/merge/runtime/diagnostic.rb', line 8

def 
  @metadata
end

#operation_idObject (readonly)

Returns the value of attribute operation_id.



8
9
10
# File 'lib/ast/merge/runtime/diagnostic.rb', line 8

def operation_id
  @operation_id
end

#severityObject (readonly)

Returns the value of attribute severity.



8
9
10
# File 'lib/ast/merge/runtime/diagnostic.rb', line 8

def severity
  @severity
end

#surface_pathObject (readonly)

Returns the value of attribute surface_path.



8
9
10
# File 'lib/ast/merge/runtime/diagnostic.rb', line 8

def surface_path
  @surface_path
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/ast/merge/runtime/diagnostic.rb', line 19

def error?
  severity == :error
end

#to_hObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/ast/merge/runtime/diagnostic.rb', line 27

def to_h
  {
    severity: severity,
    kind: kind,
    operation_id: operation_id,
    surface_path: surface_path,
    message: message,
    metadata: 
  }
end

#warning?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/ast/merge/runtime/diagnostic.rb', line 23

def warning?
  severity == :warn
end