Class: Nocode::Steps::Map

Inherits:
Nocode::Step show all
Defined in:
lib/nocode/steps/map.rb

Overview

Iterate over a register. Each iteration will store the current element and index in special registers called: _element and _index. You can prefix these registers by setting the element_register_prefix option.

The main difference between this and ‘each’ is that this will collect the iterator element register and set the register to this new collection.

Constant Summary

Constants included from Util::Optionable

Util::Optionable::OPTION_PREFIX

Instance Attribute Summary

Attributes inherited from Nocode::Step

#context, #name, #options, #type

Instance Method Summary collapse

Methods inherited from Nocode::Step

#initialize

Methods included from Util::Optionable

included, #method_missing, #options, #respond_to_missing?

Methods included from Util::Arrayable

#array

Constructor Details

This class inherits a constructor from Nocode::Step

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Nocode::Util::Optionable

Instance Method Details

#performObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/nocode/steps/map.rb', line 18

def perform
  registers[register_option] = entries.map.with_index do |entry, index|
    registers[element_key] = entry
    registers[index_key]   = index

    execute_steps

    registers[element_key]
  end
end