Sha256: 628a89d688d0363a597b5fcc13b7ddc770fdf6e4c61aa6893cd5847592d9e1c6

Contents?: true

Size: 731 Bytes

Versions: 3

Compression:

Stored size: 731 Bytes

Contents

module Itiel
  module Transform
    #
    # This transformation only selects specific columns on the data stream
    #
    # Usage:
    #
    #     @transformer = Itiel::Transform::RemoveColumn.new("order_id")
    #
    # In the example, the output stream would not have the order_id column
    #
    class RemoveColumn
      include ChainedStep
      include Itiel::Nameable

      attr_accessor :mappings

      def initialize(*args)
        self.mappings = args
      end

      def transform!(input_stream)
        selected_output = []
        input_stream.each do |object|
          selected_output << object.select {|key, value| !self.mappings.include? key }
        end

        selected_output
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
itiel-0.1.2 lib/itiel/transform/remove_column.rb
itiel-0.1.1 lib/itiel/transform/remove_column.rb
itiel-0.1.0 lib/itiel/transform/remove_column.rb