Class: Simplerubysteps::Task

Inherits:
State
  • Object
show all
Defined in:
lib/simplerubysteps.rb

Instance Attribute Summary

Attributes inherited from State

#name, #state_machine

Instance Method Summary collapse

Methods inherited from State

#[]=, #next=, #render

Constructor Details

#initialize(name) ⇒ Task

Returns a new instance of Task.



64
65
66
67
68
69
70
71
72
# File 'lib/simplerubysteps.rb', line 64

def initialize(name)
  super
  @dict[:Type] = "Task"
  @dict[:Resource] = $FUNCTION_ARN
  @dict[:Parameters] = {
    :Task => name,
    "Input.$" => "$",
  }
end

Instance Method Details

#action(&action_block) ⇒ Object



74
75
76
# File 'lib/simplerubysteps.rb', line 74

def action(&action_block)
  @action_block = action_block
end

#implicit_choiceObject



90
91
92
93
94
95
96
97
# File 'lib/simplerubysteps.rb', line 90

def implicit_choice
  unless @implicit_choice
    @implicit_choice = Choice.new("#{name}_choice")
    $sm.add @implicit_choice
    self.next = @implicit_choice
  end
  @implicit_choice
end

#perform_action(input) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/simplerubysteps.rb', line 78

def perform_action(input)
  output = nil
  output = @action_block.call(input) if @action_block

  if @implicit_choice
    output = {} unless output
    @implicit_choice.perform_action(output)
  end

  output
end