Class: Smith::Workflow::Graph::Diagnostic
- Inherits:
-
Object
- Object
- Smith::Workflow::Graph::Diagnostic
- Defined in:
- lib/smith/workflow/graph/diagnostic.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#suggestion ⇒ Object
readonly
Returns the value of attribute suggestion.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#transition ⇒ Object
readonly
Returns the value of attribute transition.
Instance Method Summary collapse
-
#initialize(**attributes) ⇒ Diagnostic
constructor
A new instance of Diagnostic.
- #message ⇒ Object
- #nested(label:, code:, transition:, target:) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(**attributes) ⇒ Diagnostic
Returns a new instance of Diagnostic.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/smith/workflow/graph/diagnostic.rb', line 11 def initialize(**attributes) @severity = attributes.fetch(:severity) @code = attributes.fetch(:code) @message = attributes.fetch(:message) @path = attributes[:path] @state = attributes[:state] @transition = attributes[:transition] @target = attributes[:target] @suggestion = attributes[:suggestion] end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
9 10 11 |
# File 'lib/smith/workflow/graph/diagnostic.rb', line 9 def code @code end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
9 10 11 |
# File 'lib/smith/workflow/graph/diagnostic.rb', line 9 def severity @severity end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
9 10 11 |
# File 'lib/smith/workflow/graph/diagnostic.rb', line 9 def state @state end |
#suggestion ⇒ Object (readonly)
Returns the value of attribute suggestion.
9 10 11 |
# File 'lib/smith/workflow/graph/diagnostic.rb', line 9 def suggestion @suggestion end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
9 10 11 |
# File 'lib/smith/workflow/graph/diagnostic.rb', line 9 def target @target end |
#transition ⇒ Object (readonly)
Returns the value of attribute transition.
9 10 11 |
# File 'lib/smith/workflow/graph/diagnostic.rb', line 9 def transition @transition end |
Instance Method Details
#message ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/smith/workflow/graph/diagnostic.rb', line 22 def return @message unless @path return @rendered_message if defined?(@rendered_message) @rendered_message = String.new.tap do |rendered| @path.each_label { |label| rendered << "Nested workflow #{label}: " } rendered << @message end.freeze end |
#nested(label:, code:, transition:, target:) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/smith/workflow/graph/diagnostic.rb', line 32 def nested(label:, code:, transition:, target:) self.class.new( severity: severity, code: code, message: @message, path: DiagnosticPath.new(label:, tail: @path), state: state, transition: transition, target: target, suggestion: suggestion ) end |
#to_h ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/smith/workflow/graph/diagnostic.rb', line 45 def to_h { severity: severity, code: code, message: , state: state, transition: transition, target: target, suggestion: suggestion }.compact end |