Sha256: f742bcac3b353032d46fc675e40cbca2ce4299a19eb527715c30fe9741654f34

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

module Topographer
  class Importer
    class Mapper
      module MappingColumns
        def output_fields
          (required_mappings.merge(optional_mappings).merge(default_values)).values.map(&:output_field)
        end

        def required_input_columns
          (required_mapping_columns + validation_mapping_columns).uniq
        end

        def input_columns
          (required_mapping_columns + optional_mapping_columns + validation_mapping_columns).uniq
        end

        def default_fields
          default_values.keys
        end

        def validation_mapping_columns
          validation_mappings.values.flat_map(&:input_columns)
        end

        def ignored_mapping_columns
          ignored_mappings.values.flat_map(&:input_columns)
        end

        def optional_mapping_columns
          optional_mappings.values.flat_map(&:input_columns)
        end

        def required_mapping_columns
          required_mappings.values.flat_map(&:input_columns)
        end

        private
        def mapped_input_columns
          required_mapping_columns + optional_mapping_columns + ignored_mapping_columns + validation_mapping_columns
        end

        def mappings
          @field_mappings
        end

        def non_ignored_columns
          required_mappings.merge(optional_mappings)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
topographer-0.0.9 lib/topographer/importer/mapper/mapping_columns.rb
topographer-0.0.8 lib/topographer/importer/mapper/mapping_columns.rb