Sha256: 06b2131a4261e0f358943681ad366d8af3c4aec75b127febbd5742164f107d70

Contents?: true

Size: 914 Bytes

Versions: 2

Compression:

Stored size: 914 Bytes

Contents

# frozen_string_literal: true

#
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#

module Burner
  class Jobs
    module Deserialize
      # Take a CSV string and de-serialize into object(s).
      # Expected Payload#value input: nothing.
      # Payload#value output: an array of arrays.  Each inner array represents one data row.
      class Csv < Job
        # This currently only supports returning an array of arrays, including the header row.
        # In the future this could be extended to offer more customizable options, such as
        # making it return an array of hashes with the columns mapped, etc.)
        def perform(_output, payload)
          payload.value = CSV.new(payload.value, headers: false).to_a

          nil
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
burner-1.0.0.pre.alpha.5 lib/burner/jobs/deserialize/csv.rb
burner-1.0.0.pre.alpha.4 lib/burner/jobs/deserialize/csv.rb