Class: AffiliateWindow::ETL::Transformer
- Inherits:
-
Object
- Object
- AffiliateWindow::ETL::Transformer
- Defined in:
- lib/affiliate_window/etl/transformer.rb
Overview
rubocop:disable Metrics/ClassLength
Defined Under Namespace
Classes: TypeError
Instance Attribute Summary collapse
-
#normaliser ⇒ Object
Returns the value of attribute normaliser.
Instance Method Summary collapse
-
#initialize(normaliser:) ⇒ Transformer
constructor
A new instance of Transformer.
- #transform(record) ⇒ Object
Constructor Details
#initialize(normaliser:) ⇒ Transformer
Returns a new instance of Transformer.
6 7 8 |
# File 'lib/affiliate_window/etl/transformer.rb', line 6 def initialize(normaliser:) self.normaliser = normaliser end |
Instance Attribute Details
#normaliser ⇒ Object
Returns the value of attribute normaliser.
4 5 6 |
# File 'lib/affiliate_window/etl/transformer.rb', line 4 def normaliser @normaliser end |
Instance Method Details
#transform(record) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/affiliate_window/etl/transformer.rb', line 10 def transform(record) record = record.dup record_type = record.fetch(:record_type) transformed_records = [] case record_type when :merchant normalise_commision_ranges!(record, transformed_records) normalise_sectors!(record, transformed_records) when :transaction normalise_transaction_parts!(record, transformed_records) when :transaction_product normalise_transaction_products!(record, transformed_records) # transaction_product has no other top-level attributes return transformed_records end attributes = infer_field_names(record) transformed_records.push(attributes) end |