Class: NdrImport::Xml::MaskedMappings
- Inherits:
-
Object
- Object
- NdrImport::Xml::MaskedMappings
- Defined in:
- lib/ndr_import/xml/masked_mappings.rb
Overview
This class applies a do_not_capture mask to those mappings that do not relate to each klass. Overriding the NdrImport::Table method to avoid memoizing. This by design, column mappings can change if new mappings are added on the fly where repeating sections are present
Instance Attribute Summary collapse
-
#augmented_columns ⇒ Object
Returns the value of attribute augmented_columns.
-
#klass ⇒ Object
Returns the value of attribute klass.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(klass, augmented_columns) ⇒ MaskedMappings
constructor
A new instance of MaskedMappings.
Constructor Details
#initialize(klass, augmented_columns) ⇒ MaskedMappings
Returns a new instance of MaskedMappings.
9 10 11 12 |
# File 'lib/ndr_import/xml/masked_mappings.rb', line 9 def initialize(klass, augmented_columns) @klass = klass @augmented_columns = augmented_columns end |
Instance Attribute Details
#augmented_columns ⇒ Object
Returns the value of attribute augmented_columns.
7 8 9 |
# File 'lib/ndr_import/xml/masked_mappings.rb', line 7 def augmented_columns @augmented_columns end |
#klass ⇒ Object
Returns the value of attribute klass.
7 8 9 |
# File 'lib/ndr_import/xml/masked_mappings.rb', line 7 def klass @klass end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ndr_import/xml/masked_mappings.rb', line 14 def call return { klass => augmented_columns } if klass.present? masked_mappings = column_level_klass_masked_mappings augmented_masked_mappings = masked_mappings # Remove any masked klasses where additional columns mappings # have been added for repeated sections # e.g. SomeTestKlass column mappings are not needed if SomeTestKlass#1 # have been added masked_mappings.each do |masked_key, columns| # There may be occasions where the e.g. SomeTestKlass should be kept, # This can be flagged in the one the klass's column mappings next if columns.any? { |column| column.dig('xml_cell', 'keep_klass') } if masked_mappings.keys.any? { |key| key =~ /\A#{masked_key}#\d+\z/ } augmented_masked_mappings.delete(masked_key) end end augmented_masked_mappings end |