Class: NdrImport::Xml::ColumnMapping
- Inherits:
-
Object
- Object
- NdrImport::Xml::ColumnMapping
- Defined in:
- lib/ndr_import/xml/column_mapping.rb
Overview
This class generates new XML column mappings where repeating columns/sections have been identified in the xml. This avoids the need for mappings to verbosly define repeating columns/sections
Instance Attribute Summary collapse
-
#build_new_record ⇒ Object
Returns the value of attribute build_new_record.
-
#existing_column ⇒ Object
Returns the value of attribute existing_column.
-
#increment_field_name ⇒ Object
Returns the value of attribute increment_field_name.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#klass_increment ⇒ Object
Returns the value of attribute klass_increment.
-
#klass_section_xpath ⇒ Object
Returns the value of attribute klass_section_xpath.
-
#repeating_item ⇒ Object
Returns the value of attribute repeating_item.
-
#unmapped_node_parts ⇒ Object
Returns the value of attribute unmapped_node_parts.
-
#xml_line ⇒ Object
Returns the value of attribute xml_line.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(existing_column, unmapped_node_parts, klass_increment, xml_line, klass) ⇒ ColumnMapping
constructor
A new instance of ColumnMapping.
Constructor Details
#initialize(existing_column, unmapped_node_parts, klass_increment, xml_line, klass) ⇒ ColumnMapping
Returns a new instance of ColumnMapping.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ndr_import/xml/column_mapping.rb', line 10 def initialize(existing_column, unmapped_node_parts, klass_increment, xml_line, klass) @existing_column = existing_column @unmapped_node_parts = unmapped_node_parts @klass_increment = klass_increment @xml_line = xml_line @klass = klass @repeating_item = existing_column.dig('xml_cell', 'multiple') @increment_field_name = existing_column.dig('xml_cell', 'increment_field_name') @build_new_record = existing_column.dig('xml_cell', 'build_new_record') @klass_section_xpath = existing_column.dig('xml_cell', 'klass_section') end |
Instance Attribute Details
#build_new_record ⇒ Object
Returns the value of attribute build_new_record.
7 8 9 |
# File 'lib/ndr_import/xml/column_mapping.rb', line 7 def build_new_record @build_new_record end |
#existing_column ⇒ Object
Returns the value of attribute existing_column.
7 8 9 |
# File 'lib/ndr_import/xml/column_mapping.rb', line 7 def existing_column @existing_column end |
#increment_field_name ⇒ Object
Returns the value of attribute increment_field_name.
7 8 9 |
# File 'lib/ndr_import/xml/column_mapping.rb', line 7 def increment_field_name @increment_field_name end |
#klass ⇒ Object
Returns the value of attribute klass.
7 8 9 |
# File 'lib/ndr_import/xml/column_mapping.rb', line 7 def klass @klass end |
#klass_increment ⇒ Object
Returns the value of attribute klass_increment.
7 8 9 |
# File 'lib/ndr_import/xml/column_mapping.rb', line 7 def klass_increment @klass_increment end |
#klass_section_xpath ⇒ Object
Returns the value of attribute klass_section_xpath.
7 8 9 |
# File 'lib/ndr_import/xml/column_mapping.rb', line 7 def klass_section_xpath @klass_section_xpath end |
#repeating_item ⇒ Object
Returns the value of attribute repeating_item.
7 8 9 |
# File 'lib/ndr_import/xml/column_mapping.rb', line 7 def repeating_item @repeating_item end |
#unmapped_node_parts ⇒ Object
Returns the value of attribute unmapped_node_parts.
7 8 9 |
# File 'lib/ndr_import/xml/column_mapping.rb', line 7 def unmapped_node_parts @unmapped_node_parts end |
#xml_line ⇒ Object
Returns the value of attribute xml_line.
7 8 9 |
# File 'lib/ndr_import/xml/column_mapping.rb', line 7 def xml_line @xml_line end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ndr_import/xml/column_mapping.rb', line 22 def call new_column = existing_column.deep_dup new_column['column'] = unmapped_node_parts[:column_name] new_column['xml_cell']['relative_path'] = unmapped_node_parts[:column_relative_path] # create unique rawtext names for repeating sections within a record apply_new_rawtext_and_mapped_names_to(new_column) if repeating_item return new_column unless incremented_klass_needed? new_column['klass'] = incremented_klass new_column end |