Class: RubyReactor::Step::MapStep

Inherits:
Object
  • Object
show all
Includes:
RubyReactor::Step
Defined in:
lib/ruby_reactor/step/map_step.rb

Class Method Summary collapse

Methods included from RubyReactor::Step

included

Class Method Details

.build_mapped_inputs(mappings, context, element) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ruby_reactor/step/map_step.rb', line 27

def build_mapped_inputs(mappings, context, element)
  inputs = {}

  mappings.each do |mapped_input_name, source|
    value = if source.is_a?(RubyReactor::Template::Element)
              # Handle element reference
              # For now assuming element() refers to the current map's element
              # In nested maps, we might need to check the name, but for now simple case
              resolve_element(source, element)
            else
              source.resolve(context)
            end
    inputs[mapped_input_name] = value
  end

  inputs
end

.compensate(_reason, _arguments, _context) ⇒ Object



21
22
23
24
# File 'lib/ruby_reactor/step/map_step.rb', line 21

def self.compensate(_reason, _arguments, _context)
  # TODO: Implement compensation for map steps
  RubyReactor.Success()
end

.resolve_element(template_element, current_element) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/ruby_reactor/step/map_step.rb', line 45

def resolve_element(template_element, current_element)
  # If path is provided, extract it
  if template_element.path
    extract_path(current_element, template_element.path)
  else
    current_element
  end
end

.run(arguments, context) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ruby_reactor/step/map_step.rb', line 8

def self.run(arguments, context)
  return RubyReactor::Failure("Map source cannot be nil") if arguments[:source].nil?

  # Initialize map state in context if not present
  context.map_operations ||= {}

  if should_run_async?(arguments, context)
    run_async(arguments, context, context.current_step)
  else
    run_inline(arguments, context)
  end
end