Class: NdrImport::Xml::MaskedMappings

Inherits:
Object
  • Object
show all
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

Constant Summary collapse

DO_NOT_CAPTURE_MAPPING =
{ 'do_not_capture' => true }.freeze
KLASS_KEY =
'klass'.freeze
COLUMN_KEY =
'column'.freeze
STANDARD_MAPPING_KEY =
'standard_mapping'.freeze
DO_NOT_CAPTURE_KEY =
'do_not_capture'.freeze
XML_CELL_KEY =
'xml_cell'.freeze
KEEP_KLASS_KEY =
'keep_klass'.freeze
NUMBERED_VARIANT_PATTERN =

Pre-compiled regex for numbered variants

/#\d+\z/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, augmented_columns) ⇒ MaskedMappings

Returns a new instance of MaskedMappings.



20
21
22
23
24
25
26
27
# File 'lib/ndr_import/xml/masked_mappings.rb', line 20

def initialize(klass, augmented_columns)
  @klass             = klass
  @augmented_columns = augmented_columns
  @column_count      = augmented_columns.size
  @has_klass         = !klass.nil?

  freeze
end

Instance Attribute Details

#augmented_columnsObject (readonly)

Returns the value of attribute augmented_columns.



18
19
20
# File 'lib/ndr_import/xml/masked_mappings.rb', line 18

def augmented_columns
  @augmented_columns
end

#klassObject (readonly)

Returns the value of attribute klass.



18
19
20
# File 'lib/ndr_import/xml/masked_mappings.rb', line 18

def klass
  @klass
end

Instance Method Details

#callObject



29
30
31
32
33
34
# File 'lib/ndr_import/xml/masked_mappings.rb', line 29

def call
  return { @klass => @augmented_columns } if @has_klass

  masked_mappings = build_masked_mappings
  remove_superseded_base_klasses(masked_mappings)
end