Class: AffiliateWindow::ETL::Normaliser
- Inherits:
-
Object
- Object
- AffiliateWindow::ETL::Normaliser
- Defined in:
- lib/affiliate_window/etl/normaliser.rb
Instance Method Summary collapse
-
#normalise!(record, field_name:, nested_name:, foreign_name:, id_name: :i_id, record_type: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists, Metrics/LineLength.
Instance Method Details
#normalise!(record, field_name:, nested_name:, foreign_name:, id_name: :i_id, record_type: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists, Metrics/LineLength
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/affiliate_window/etl/normaliser.rb', line 4 def normalise!(record, field_name:, nested_name:, foreign_name:, id_name: :i_id, record_type: nil) # rubocop:disable Metrics/ParameterLists, Metrics/LineLength record_type ||= nested_name value = record.delete(field_name) return [] unless value elements = [value.fetch(nested_name)].flatten foreign_id = record.fetch(id_name) elements.map do |attributes| attributes.merge( record_type: record_type, foreign_name => foreign_id, ) end end |