Class: ETL::Processor::FilterRowProcessor

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from RowProcessor

#ensure_columns_available_in_row!

Constructor Details

#initialize(control, configuration) ⇒ FilterRowProcessor

Returns a new instance of FilterRowProcessor.



8
9
10
11
12
13
# File 'lib/etl/processor/filter_row_processor.rb', line 8

def initialize(control, configuration)
  @condition = configuration[:condition]
  @outtrue = configuration[:outtrue]
  @outfalse = configuration[:outfalse]
  super
end

Instance Attribute Details

#conditionObject (readonly)

Returns the value of attribute condition.



4
5
6
# File 'lib/etl/processor/filter_row_processor.rb', line 4

def condition
  @condition
end

#outfalseObject (readonly)

Returns the value of attribute outfalse.



6
7
8
# File 'lib/etl/processor/filter_row_processor.rb', line 6

def outfalse
  @outfalse
end

#outtrueObject (readonly)

Returns the value of attribute outtrue.



5
6
7
# File 'lib/etl/processor/filter_row_processor.rb', line 5

def outtrue
  @outtrue
end

Instance Method Details

#process(row) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/etl/processor/filter_row_processor.rb', line 15

def process(row)
  return nil if row.nil?

  if eval_condition(row, @condition)
    return [] if @outtrue.nil?

    eval(@outtrue)
  else
    eval(@outfalse) unless @outfalse.nil?
  end

  return row
end