Class: DurableFlow::DefinitionAnalyzer
- Inherits:
-
Object
- Object
- DurableFlow::DefinitionAnalyzer
- Defined in:
- lib/durable_flow/definition_analyzer.rb
Defined Under Namespace
Classes: Path
Constant Summary collapse
- STEP_PROXY_CALLS =
%i[ run sleep sleep_until wait_for_event invoke invoke_each call call_each child_workflow child_workflows each_child_workflow ].freeze
- WORKFLOW_CALLS =
%i[invoke call child_workflow].freeze
- FANOUT_CALLS =
%i[invoke_each call_each child_workflows each_child_workflow].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(workflow_class) ⇒ DefinitionAnalyzer
constructor
A new instance of DefinitionAnalyzer.
Constructor Details
#initialize(workflow_class) ⇒ DefinitionAnalyzer
Returns a new instance of DefinitionAnalyzer.
32 33 34 35 36 |
# File 'lib/durable_flow/definition_analyzer.rb', line 32 def initialize(workflow_class) @workflow_class = workflow_class @source_file, @perform_line = workflow_class.instance_method(:perform).source_location @graph = DefinitionGraph.new(workflow_class: workflow_class.name, source_file: source_file) end |
Class Method Details
.call(workflow_class) ⇒ Object
27 28 29 |
# File 'lib/durable_flow/definition_analyzer.rb', line 27 def call(workflow_class) new(workflow_class).call end |
Instance Method Details
#call ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/durable_flow/definition_analyzer.rb', line 38 def call result = Prism.parse_file(source_file) result.errors.each do |error| graph.warnings << "Parse warning at #{source_file}:#{error.location.start_line}: #{error.}" end perform_node = find_perform_node(result.value) unless perform_node graph.warnings << "Could not locate #{workflow_class.name}#perform at #{source_file}:#{perform_line}" return graph end body = perform_node.body&.body || [] analyze_statements(body, [ Path.new(nil, nil) ]) graph end |