Class: Nocode::Steps::Record::Map

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

Overview

Create a new hash from an existing hash mapping each key as configured by the key_mappings option. The key_mappings option should be in the form of:

new_key => old_key

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



12
13
14
15
16
17
18
19
20
21
# File 'lib/nocode/steps/record/map.rb', line 12

def perform
  input  = registers[register_option] || {}
  output = {}

  (key_mappings_option || {}).each do |to, from|
    output[to.to_s] = input[from.to_s]
  end

  registers[register_option] = output
end