Class: Browserctl::WorkflowDefinition

Inherits:
CallableDefinition show all
Defined in:
lib/browserctl/workflow.rb

Instance Attribute Summary

Attributes inherited from CallableDefinition

#description, #name, #param_defs, #steps

Instance Method Summary collapse

Methods inherited from CallableDefinition

#desc, #initialize, #param, #step

Constructor Details

This class inherits a constructor from Browserctl::CallableDefinition

Instance Method Details

#call(params, client, replay_context: nil) ⇒ Object



334
335
336
337
# File 'lib/browserctl/workflow.rb', line 334

def call(params, client, replay_context: nil)
  ctx = WorkflowContext.new(resolve_params(params), client, replay_context: replay_context)
  execute_steps(ctx)
end

#callable_kindObject



312
313
314
# File 'lib/browserctl/workflow.rb', line 312

def callable_kind
  :workflow
end

#compose(workflow_name) ⇒ Object

Definition-time guard: composing a flow into a workflow would copy flow steps that may close over ‘page` (a flow-only DSL) into a context that doesn’t expose it. Cross-kind composition is rejected here rather than failing later inside an ‘instance_exec`.

Raises:



320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/browserctl/workflow.rb', line 320

def compose(workflow_name)
  name = workflow_name.to_s
  if Browserctl.lookup_flow(name)
    raise ArgumentError,
          "workflow '#{@name}' cannot compose flow '#{name}': flows return state, " \
          "workflows share state — composition across kinds is not supported"
  end

  source = Browserctl.lookup_workflow(name)
  raise WorkflowError, "workflow '#{workflow_name}' not found for composition" unless source

  @steps.concat(source.steps)
end