Module: MiniOperation::InstanceMethods

Defined in:
lib/mini_operation.rb

Overview

Contains the instance method helpers like: perform, previous_step, next_step and others

Instance Method Summary collapse

Instance Method Details

#performObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mini_operation.rb', line 17

def perform
  default_data = { results: {}, errors: {}, steps_map: {}, current_step: -1, execution_path: [] }
  instance_variable_set(:@__mini_operation_data, default_data)

  steps = self.class.class_variable_get(:@@__mini_operation_steps)
  steps.each_with_index do |step, index|
    @__mini_operation_data[:current_step] = index
    @__mini_operation_data[:results][step] = send(step)
    @__mini_operation_data[:execution_path] << step
  rescue StandardError => e
    @__mini_operation_data[:errors][step] = e
  end
end