Class: ETL::Processor::RequireNonBlankProcessor

Inherits:
RowProcessor show all
Defined in:
lib/etl/processor/require_non_blank_processor.rb

Overview

A processor which requires that the particular fields are non-blank in order for the row to be retained.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(control, configuration) ⇒ RequireNonBlankProcessor

Initialize the processor

Options:

  • :fields: An array of fields to check, for example:

    :first_name,:last_name


14
15
16
17
# File 'lib/etl/processor/require_non_blank_processor.rb', line 14

def initialize(control, configuration)
  super
  @fields = configuration[:fields] || []
end

Instance Attribute Details

#fieldsObject (readonly)

An array of fields to check



7
8
9
# File 'lib/etl/processor/require_non_blank_processor.rb', line 7

def fields
  @fields
end

Instance Method Details

#process(row) ⇒ Object

Process the row.



20
21
22
23
# File 'lib/etl/processor/require_non_blank_processor.rb', line 20

def process(row)
  fields.each { |field| return if row[field].blank? }
  row
end