Class: Snoot::Run
- Inherits:
-
Data
- Object
- Data
- Snoot::Run
- Defined in:
- lib/snoot/run.rb
Overview
One analysis pass: the input paths, the outcome (pending, finding_rendered, nothing_to_report, analysis_failed), and the selected_finding when one was chosen. Enforces the transition rules and the presence invariants – selected_finding iff finding_rendered, failure iff analysis_failed.
Instance Attribute Summary collapse
-
#failure ⇒ Object
readonly
Returns the value of attribute failure.
-
#outcome ⇒ Object
readonly
Returns the value of attribute outcome.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#selected_finding ⇒ Object
readonly
Returns the value of attribute selected_finding.
Instance Method Summary collapse
-
#initialize(paths:, outcome:, selected_finding: nil, failure: nil) ⇒ Run
constructor
A new instance of Run.
- #transition_to(target, selected_finding: nil, failure: nil) ⇒ Object
Constructor Details
#initialize(paths:, outcome:, selected_finding: nil, failure: nil) ⇒ Run
Returns a new instance of Run.
10 11 12 13 14 |
# File 'lib/snoot/run.rb', line 10 def initialize(paths:, outcome:, selected_finding: nil, failure: nil) super enforce_field_when!(:selected_finding, outcome: :finding_rendered) enforce_field_when!(:failure, outcome: :analysis_failed) end |
Instance Attribute Details
#failure ⇒ Object (readonly)
Returns the value of attribute failure
9 10 11 |
# File 'lib/snoot/run.rb', line 9 def failure @failure end |
#outcome ⇒ Object (readonly)
Returns the value of attribute outcome
9 10 11 |
# File 'lib/snoot/run.rb', line 9 def outcome @outcome end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths
9 10 11 |
# File 'lib/snoot/run.rb', line 9 def paths @paths end |
#selected_finding ⇒ Object (readonly)
Returns the value of attribute selected_finding
9 10 11 |
# File 'lib/snoot/run.rb', line 9 def selected_finding @selected_finding end |
Instance Method Details
#transition_to(target, selected_finding: nil, failure: nil) ⇒ Object
16 17 18 19 20 |
# File 'lib/snoot/run.rb', line 16 def transition_to(target, selected_finding: nil, failure: nil) raise StateError, "transition #{outcome} -> #{target} is not declared" unless outcome == :pending with(outcome: target, selected_finding: selected_finding, failure: failure) end |