Module: WorkflowTemplate::Workflow::ModuleMethods

Instance Method Summary collapse

Methods included from Performer

perform_action, perform_actions, perform_wrapper_action, perform_wrapper_actions

Methods included from Definer::HasValidations

#declare_validation, #default_validation_adapter, #freeze, #validate_input, #validate_output

Methods included from Definer::HasStateAdapter

#freeze, #state_adapter

Methods included from Definer::HasOutputNormalizer

#freeze, #normalize_output

Methods included from Definer::HasDefaultStateTransitionStrategy

#default_state_transition_strategy, #freeze

Methods included from Definer::HasActions::Root

#prepare_action, #prepare_actions

Methods included from Definer::HasActions::Dsl

#append_action, #apply, #inside_action, #prepend_action, #remove_action, #replace_action, #wrap_template

Methods included from Definer::HasActions

#actions, #freeze

Instance Method Details

#describeObject

Raises:



46
47
48
49
50
# File 'lib/workflow_template/workflow.rb', line 46

def describe
  raise Error, "Can't describe unfrozen workflow" unless frozen?

  Description.describe(self)
end

#perform(input, receiver, trace: false) ⇒ Object

rubocop:disable Metrics/AbcSize



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/workflow_template/workflow.rb', line 25

def perform(input, receiver, trace: false) # rubocop:disable Metrics/AbcSize
  state_class = State.state_class(state_adapter)
  state = state_class.initial(
    input,
    default_state_transition_strategy,
    validations.input_validations,
    trace: trace
  )
  state = super(state, receiver) if state.continue?
  state = state.normalize_data(output_normalizer)
  state = state.apply_validations(validations.output_validations)
  Outcome.new(state.final)
rescue Fatal
  raise
rescue StandardError => e
  raise Fatal, "Unable to initialize state class: #{e}" unless state_class
  raise Fatal, "Unable to initialize state: #{e}" unless state

  raise Fatal, "Unexpected error: #{e}"
end