Sha256: 00c9ede749fc1364a06a1ea71c677a72537a6e0daaec47440b744ce97902a893

Contents?: true

Size: 637 Bytes

Versions: 3

Compression:

Stored size: 637 Bytes

Contents

# frozen_string_literal: true

module Nocode
  module Steps
    module Record
      # 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
      class Map < Step
        option :key_mappings, :register

        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
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nocode-0.0.10 lib/nocode/steps/record/map.rb
nocode-0.0.9 lib/nocode/steps/record/map.rb
nocode-0.0.8 lib/nocode/steps/record/map.rb