Class: Itiel::Transform::RemoveColumn

Inherits:
Object
  • Object
show all
Includes:
Nameable, ChainedStep
Defined in:
lib/itiel/transform/remove_column.rb

Overview

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

Instance Attribute Summary collapse

Attributes included from Nameable

#debug, #step_name

Attributes included from ChainedStep

#next_step

Instance Method Summary collapse

Methods included from ChainedStep

#input=

Constructor Details

#initialize(*args) ⇒ RemoveColumn

Returns a new instance of RemoveColumn.



18
19
20
# File 'lib/itiel/transform/remove_column.rb', line 18

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

Instance Attribute Details

#mappingsObject

Returns the value of attribute mappings.



16
17
18
# File 'lib/itiel/transform/remove_column.rb', line 16

def mappings
  @mappings
end

Instance Method Details

#transform!(input_stream) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/itiel/transform/remove_column.rb', line 22

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