Sha256: a7f7c4666089d757170be343defcbb8ae021555092cc428c637eccd3c96e1b41

Contents?: true

Size: 971 Bytes

Versions: 53

Compression:

Stored size: 971 Bytes

Contents

# encoding: UTF-8
require 'ndr_import/non_tabular/table'

module NdrImport
  module NonTabular
    # This class stores the mapping used to break an incoming file into multiple rows/records
    class Mapping < Table
      def self.all_valid_options
        super + %w(non_tabular_row)
      end

      def initialize(options)
        non_tabular_mappings = options['non_tabular_row']
        if non_tabular_mappings
          initialize_non_tabular_mappings(non_tabular_mappings)
        else
          # validate presence of non_tabular_row
          fail NdrImport::MappingError,
               I18n.t('mapping.errors.missing_non_tabular_row')
        end

        super(options)
      end

      private

      def initialize_non_tabular_mappings(non_tabular_mappings)
        NON_TABULAR_OPTIONS.each do |key|
          next unless non_tabular_mappings[key]
          instance_variable_set("@#{key}", non_tabular_mappings[key])
        end
      end
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
ndr_import-11.2.1 lib/ndr_import/non_tabular/mapping.rb
ndr_import-11.2.0 lib/ndr_import/non_tabular/mapping.rb
ndr_import-11.1.0 lib/ndr_import/non_tabular/mapping.rb
ndr_import-11.0.2 lib/ndr_import/non_tabular/mapping.rb
ndr_import-11.0.1 lib/ndr_import/non_tabular/mapping.rb
ndr_import-11.0.0 lib/ndr_import/non_tabular/mapping.rb
ndr_import-10.3.0 lib/ndr_import/non_tabular/mapping.rb
ndr_import-10.2.0 lib/ndr_import/non_tabular/mapping.rb
ndr_import-10.1.3 lib/ndr_import/non_tabular/mapping.rb
ndr_import-10.1.2 lib/ndr_import/non_tabular/mapping.rb
ndr_import-10.1.1 lib/ndr_import/non_tabular/mapping.rb
ndr_import-10.1 lib/ndr_import/non_tabular/mapping.rb
ndr_import-10.0 lib/ndr_import/non_tabular/mapping.rb
ndr_import-9.1.0 lib/ndr_import/non_tabular/mapping.rb
ndr_import-9.0.3 lib/ndr_import/non_tabular/mapping.rb
ndr_import-9.0.2 lib/ndr_import/non_tabular/mapping.rb
ndr_import-9.0.1 lib/ndr_import/non_tabular/mapping.rb
ndr_import-9.0.0 lib/ndr_import/non_tabular/mapping.rb
ndr_import-8.6.0 lib/ndr_import/non_tabular/mapping.rb
ndr_import-8.5.2 lib/ndr_import/non_tabular/mapping.rb