Class: ETL::Processor::DatabaseJoinProcessor
- Inherits:
-
RowProcessor
- Object
- Processor
- RowProcessor
- ETL::Processor::DatabaseJoinProcessor
- Defined in:
- lib/etl/processor/database_join_processor.rb
Instance Attribute Summary (collapse)
-
- (Object) fields
readonly
Returns the value of attribute fields.
-
- (Object) query
readonly
Returns the value of attribute query.
-
- (Object) target
readonly
Returns the value of attribute target.
Instance Method Summary (collapse)
-
- (DatabaseJoinProcessor) initialize(control, configuration)
constructor
Initialize the procesor.
- - (Object) process(row)
-
- (Object) to_s
Get a String identifier for the source.
Constructor Details
- (DatabaseJoinProcessor) initialize(control, configuration)
Initialize the procesor.
Arguments:
-
control: The ETL::Control::Control instance
-
configuration: The configuration Hash
-
definition: The source definition
Required configuration options:
-
:target: The target connection
-
:query: The join query
-
:fields: The fields to add to the row
19 20 21 22 23 24 |
# File 'lib/etl/processor/database_join_processor.rb', line 19 def initialize(control, configuration) super @target = configuration[:target] @query = configuration[:query] @fields = configuration[:fields] end |
Instance Attribute Details
- (Object) fields (readonly)
Returns the value of attribute fields
6 7 8 |
# File 'lib/etl/processor/database_join_processor.rb', line 6 def fields @fields end |
- (Object) query (readonly)
Returns the value of attribute query
5 6 7 |
# File 'lib/etl/processor/database_join_processor.rb', line 5 def query @query end |
- (Object) target (readonly)
Returns the value of attribute target
4 5 6 |
# File 'lib/etl/processor/database_join_processor.rb', line 4 def target @target end |
Instance Method Details
- (Object) process(row)
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/etl/processor/database_join_processor.rb', line 31 def process(row) return nil if row.nil? q = @query begin q = eval('"' + @query + '"') rescue end ETL::Engine.logger.debug("Executing select: #{q}") res = connection.execute(q) res.each_hash do |r| @fields.each do |field| row[field.to_sym] = r[field] end end return row end |
- (Object) to_s
Get a String identifier for the source
27 28 29 |
# File 'lib/etl/processor/database_join_processor.rb', line 27 def to_s "#{host}/#{database}" end |