Class: Simplerubysteps::Task

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

Instance Attribute Summary collapse

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.



160
161
162
163
164
165
166
167
168
# File 'lib/simplerubysteps/model.rb', line 160

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

Instance Attribute Details

#iam_permissionsObject

Returns the value of attribute iam_permissions.



158
159
160
# File 'lib/simplerubysteps/model.rb', line 158

def iam_permissions
  @iam_permissions
end

Instance Method Details

#action(&action_block) ⇒ Object



191
192
193
# File 'lib/simplerubysteps/model.rb', line 191

def action(&action_block)
  @action_block = action_block
end

#error_catch(state) ⇒ Object



181
182
183
184
185
186
187
188
189
# File 'lib/simplerubysteps/model.rb', line 181

def error_catch(state)
  @dict[:Catch] = [
    {
      :ErrorEquals => ["States.ALL"],
      :Next => (state.is_a? Symbol) ? state : state.name,
      :ResultPath => "$.error",
    },
  ]
end

#error_retry(interval, max, backoff) ⇒ Object



170
171
172
173
174
175
176
177
178
179
# File 'lib/simplerubysteps/model.rb', line 170

def error_retry(interval, max, backoff)
  @dict[:Retry] = [
    {
      :ErrorEquals => ["States.ALL"],
      :IntervalSeconds => interval,
      :BackoffRate => backoff,
      :MaxAttempts => max,
    },
  ]
end

#implicit_choiceObject



208
209
210
211
212
213
214
215
# File 'lib/simplerubysteps/model.rb', line 208

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



195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/simplerubysteps/model.rb', line 195

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