Class: Smith::Workflow::Graph
- Inherits:
-
Object
- Object
- Smith::Workflow::Graph
- Defined in:
- lib/smith/workflow/graph.rb,
lib/smith/workflow/graph/report.rb,
lib/smith/workflow/graph/metrics.rb,
lib/smith/workflow/graph/targets.rb,
lib/smith/workflow/graph/reference.rb,
lib/smith/workflow/graph/validator.rb,
lib/smith/workflow/graph/diagnostic.rb,
lib/smith/workflow/graph/reachability.rb,
lib/smith/workflow/graph/diagnostic_path.rb,
lib/smith/workflow/graph/fanout_contract.rb,
lib/smith/workflow/graph/contract_helpers.rb,
lib/smith/workflow/graph/runtime_readiness.rb,
lib/smith/workflow/graph/state_diagnostics.rb,
lib/smith/workflow/graph/transition_contract.rb,
lib/smith/workflow/graph/transition_snapshot.rb,
lib/smith/workflow/graph/execution_successors.rb,
lib/smith/workflow/graph/identifier_projection.rb,
lib/smith/workflow/graph/optimization_contract.rb,
lib/smith/workflow/graph/orchestration_contract.rb,
lib/smith/workflow/graph/transition_diagnostics.rb,
lib/smith/workflow/graph/retry_policy_diagnostic.rb,
lib/smith/workflow/graph/reachability_diagnostics.rb,
lib/smith/workflow/graph/runtime_readiness_report.rb,
lib/smith/workflow/graph/runtime_readiness_metrics.rb,
lib/smith/workflow/graph/runtime_binding_diagnostics.rb,
lib/smith/workflow/graph/runtime_readiness_traversal.rb,
lib/smith/workflow/graph/nested_readiness_diagnostics.rb,
lib/smith/workflow/graph/transition_contract_attributes.rb,
lib/smith/workflow/graph/runtime_readiness_report_builder.rb,
lib/smith/workflow/graph/runtime_binding_diagnostic_builder.rb,
lib/smith/workflow/graph/transition_contract_configurations.rb,
lib/smith/workflow/graph/transition_optimization_configuration.rb
Defined Under Namespace
Modules: ContractHelpers, Reference Classes: Diagnostic, DiagnosticPath, ExecutionSuccessors, FanoutContract, IdentifierProjection, Metrics, NestedReadinessDiagnostics, OptimizationContract, OrchestrationContract, Reachability, ReachabilityDiagnostics, Report, RetryPolicyDiagnostic, RuntimeBindingDiagnosticBuilder, RuntimeBindingDiagnostics, RuntimeReadiness, RuntimeReadinessMetrics, RuntimeReadinessReport, RuntimeReadinessReportBuilder, RuntimeReadinessTraversal, StateDiagnostics, Targets, TransitionContract, TransitionContractAttributes, TransitionContractConfigurations, TransitionDiagnostics, TransitionOptimizationConfiguration, TransitionSnapshot, Validator
Constant Summary collapse
- EMPTY_TRANSITIONS =
[].freeze
Instance Attribute Summary collapse
-
#initial_state ⇒ Object
readonly
Returns the value of attribute initial_state.
-
#states ⇒ Object
readonly
Returns the value of attribute states.
-
#transitions ⇒ Object
readonly
Returns the value of attribute transitions.
-
#workflow_class ⇒ Object
readonly
Returns the value of attribute workflow_class.
Instance Method Summary collapse
- #first_transition_from(state) ⇒ Object
-
#initialize(workflow_class:, initial_state:, states:, transitions:) ⇒ Graph
constructor
A new instance of Graph.
- #reachable_transitions ⇒ Object
- #runtime_readiness(visited: nil) ⇒ Object
- #state?(state) ⇒ Boolean
- #transition_snapshots ⇒ Object
- #transitions_from(state) ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(workflow_class:, initial_state:, states:, transitions:) ⇒ Graph
Returns a new instance of Graph.
10 11 12 13 14 15 16 17 18 |
# File 'lib/smith/workflow/graph.rb', line 10 def initialize(workflow_class:, initial_state:, states:, transitions:) @identifier_projection = IdentifierProjection.new @workflow_class = workflow_class @initial_state = project_identifier(initial_state) @states = own_states(states) @state_index = index_states @transitions = own_transitions(transitions) @transitions_by_state = build_transitions_by_state end |
Instance Attribute Details
#initial_state ⇒ Object (readonly)
Returns the value of attribute initial_state.
8 9 10 |
# File 'lib/smith/workflow/graph.rb', line 8 def initial_state @initial_state end |
#states ⇒ Object (readonly)
Returns the value of attribute states.
8 9 10 |
# File 'lib/smith/workflow/graph.rb', line 8 def states @states end |
#transitions ⇒ Object (readonly)
Returns the value of attribute transitions.
8 9 10 |
# File 'lib/smith/workflow/graph.rb', line 8 def transitions @transitions end |
#workflow_class ⇒ Object (readonly)
Returns the value of attribute workflow_class.
8 9 10 |
# File 'lib/smith/workflow/graph.rb', line 8 def workflow_class @workflow_class end |
Instance Method Details
#first_transition_from(state) ⇒ Object
38 39 40 |
# File 'lib/smith/workflow/graph.rb', line 38 def first_transition_from(state) transitions_from(state).first end |
#reachable_transitions ⇒ Object
42 43 44 |
# File 'lib/smith/workflow/graph.rb', line 42 def reachable_transitions @reachable_transitions ||= Reachability.new(self).each_transition.to_a.freeze end |
#runtime_readiness(visited: nil) ⇒ Object
24 25 26 |
# File 'lib/smith/workflow/graph.rb', line 24 def runtime_readiness(visited: nil) RuntimeReadiness.new(self, visited: visited).report end |
#state?(state) ⇒ Boolean
46 47 48 |
# File 'lib/smith/workflow/graph.rb', line 46 def state?(state) @state_index.key?(state) end |
#transition_snapshots ⇒ Object
28 29 30 31 32 |
# File 'lib/smith/workflow/graph.rb', line 28 def transition_snapshots transitions.values.map do |transition| TransitionSnapshot.from_transition(transition, workflow_class: workflow_class) end end |
#transitions_from(state) ⇒ Object
34 35 36 |
# File 'lib/smith/workflow/graph.rb', line 34 def transitions_from(state) @transitions_by_state.fetch(state, EMPTY_TRANSITIONS) end |