Class: Simplerubysteps::Task

Inherits:
State
  • Object
show all
Defined in:
lib/simplerubysteps/model.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.



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

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

Instance Method Details

#action(&action_block) ⇒ Object



90
91
92
# File 'lib/simplerubysteps/model.rb', line 90

def action(&action_block)
  @action_block = action_block
end

#implicit_choiceObject



107
108
109
110
111
112
113
114
# File 'lib/simplerubysteps/model.rb', line 107

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



94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/simplerubysteps/model.rb', line 94

def perform_action(input)
  output = input # default: pass through

  output = @action_block.call(input) if @action_block

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

  output
end