Class: Floe::Workflow::States::Wait

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

Instance Attribute Summary collapse

Attributes inherited from Floe::Workflow::State

#comment, #name, #payload, #type

Instance Method Summary collapse

Methods included from NonTerminalMixin

#validate_state_next!

Methods inherited from Floe::Workflow::State

build!, #finished?, #long_name, #mark_error, #mark_finished, #mark_started, #ready?, #run_nonblock!, #short_name, #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) ⇒ Wait

Returns a new instance of Wait.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/floe/workflow/states/wait.rb', line 13

def initialize(workflow, name, payload)
  super

  @next           = payload["Next"]
  @end            = !!payload["End"]
  @seconds        = payload["Seconds"]&.to_i
  @timestamp      = payload["Timestamp"]
  @timestamp_path = Path.new(payload["TimestampPath"]) if payload.key?("TimestampPath")
  @seconds_path   = Path.new(payload["SecondsPath"]) if payload.key?("SecondsPath")

  @input_path  = Path.new(payload.fetch("InputPath", "$"))
  @output_path = Path.new(payload.fetch("OutputPath", "$"))

  validate_state!(workflow)
end

Instance Attribute Details

#endObject (readonly)

Returns the value of attribute end.



11
12
13
# File 'lib/floe/workflow/states/wait.rb', line 11

def end
  @end
end

#input_pathObject (readonly)

Returns the value of attribute input_path.



11
12
13
# File 'lib/floe/workflow/states/wait.rb', line 11

def input_path
  @input_path
end

#nextObject (readonly)

Returns the value of attribute next.



11
12
13
# File 'lib/floe/workflow/states/wait.rb', line 11

def next
  @next
end

#output_pathObject (readonly)

Returns the value of attribute output_path.



11
12
13
# File 'lib/floe/workflow/states/wait.rb', line 11

def output_path
  @output_path
end

#secondsObject (readonly)

Returns the value of attribute seconds.



11
12
13
# File 'lib/floe/workflow/states/wait.rb', line 11

def seconds
  @seconds
end

#seconds_pathObject (readonly)

Returns the value of attribute seconds_path.



11
12
13
# File 'lib/floe/workflow/states/wait.rb', line 11

def seconds_path
  @seconds_path
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



11
12
13
# File 'lib/floe/workflow/states/wait.rb', line 11

def timestamp
  @timestamp
end

#timestamp_pathObject (readonly)

Returns the value of attribute timestamp_path.



11
12
13
# File 'lib/floe/workflow/states/wait.rb', line 11

def timestamp_path
  @timestamp_path
end

Instance Method Details

#end?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/floe/workflow/states/wait.rb', line 51

def end?
  @end
end

#finish(context) ⇒ Object



41
42
43
44
45
# File 'lib/floe/workflow/states/wait.rb', line 41

def finish(context)
  input          = input_path.value(context, context.input)
  context.output = output_path.value(context, input)
  super
end

#running?(context) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/floe/workflow/states/wait.rb', line 47

def running?(context)
  waiting?(context)
end

#start(context) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/floe/workflow/states/wait.rb', line 29

def start(context)
  super

  input = input_path.value(context, context.input)

  wait_until!(
    context,
    :seconds => seconds_path ? seconds_path.value(context, input).to_i : seconds,
    :time    => timestamp_path ? timestamp_path.value(context, input) : timestamp
  )
end