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)

Methods inherited from RowProcessor

#ensure_columns_available_in_row!

Constructor Details

- (RequireNonBlankProcessor) initialize(control, configuration)

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

- (Object) fields (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

- (Object) process(row)

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