Class: Floe::Workflow::States::Fail

Inherits:
Floe::Workflow::State show all
Defined in:
lib/floe/workflow/states/fail.rb

Instance Attribute Summary collapse

Attributes inherited from Floe::Workflow::State

#comment, #name, #payload, #type

Instance Method Summary collapse

Methods inherited from Floe::Workflow::State

build!, #finished?, #long_name, #mark_error, #mark_finished, #mark_started, #ready?, #run_nonblock!, #short_name, #start, #started?, #wait, #wait_until, #waiting?

Methods included from ValidationMixin

included, #invalid_field_error!, #missing_field_error!, #parser_error!, #runtime_field_error!, #workflow_state?, #wrap_parser_error

Constructor Details

#initialize(workflow, name, payload) ⇒ Fail

Returns a new instance of Fail.



9
10
11
12
13
14
15
16
# File 'lib/floe/workflow/states/fail.rb', line 9

def initialize(workflow, name, payload)
  super

  @cause      = payload["Cause"]
  @error      = payload["Error"]
  @cause_path = Path.new(payload["CausePath"]) if payload["CausePath"]
  @error_path = Path.new(payload["ErrorPath"]) if payload["ErrorPath"]
end

Instance Attribute Details

#causeObject (readonly)

Returns the value of attribute cause.



7
8
9
# File 'lib/floe/workflow/states/fail.rb', line 7

def cause
  @cause
end

#cause_pathObject (readonly)

Returns the value of attribute cause_path.



7
8
9
# File 'lib/floe/workflow/states/fail.rb', line 7

def cause_path
  @cause_path
end

#errorObject (readonly)

Returns the value of attribute error.



7
8
9
# File 'lib/floe/workflow/states/fail.rb', line 7

def error
  @error
end

#error_pathObject (readonly)

Returns the value of attribute error_path.



7
8
9
# File 'lib/floe/workflow/states/fail.rb', line 7

def error_path
  @error_path
end

Instance Method Details

#end?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/floe/workflow/states/fail.rb', line 34

def end?
  true
end

#finish(context) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/floe/workflow/states/fail.rb', line 18

def finish(context)
  context.next_state = nil
  # TODO: support intrinsic functions here
  # see https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-fail-state.html
  #     https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html#asl-intrsc-func-generic
  context.output     = {
    "Error" => @error_path ? @error_path.value(context, context.input) : error,
    "Cause" => @cause_path ? @cause_path.value(context, context.input) : cause
  }.compact
  super
end

#running?(_) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/floe/workflow/states/fail.rb', line 30

def running?(_)
  false
end