Sha256: 0cb1907907dced0ffd37ff1df1d3cf99b7e562ad4c52da2c1ffad5cbafdffece

Contents?: true

Size: 729 Bytes

Versions: 2

Compression:

Stored size: 729 Bytes

Contents

module Topographer
  class Importer
    class Mapper
      class DefaultFieldMapping < Topographer::Importer::Mapper::FieldMapping

        def initialize(output_column, &output_block)
          unless block_given?
            raise Topographer::InvalidMappingError, 'Static fields must have an output block'
          end
          @output_field = output_column
          @output_block = output_block
        end

        def process_input(_, result)
          @output_data = @output_block.()
          result.add_data(@output_field, @output_data)
        rescue => exception
          result.add_error(@output_field, exception.message)
        end

        def required?
          true
        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/default_field_mapping.rb
topographer-0.0.8 lib/topographer/importer/mapper/default_field_mapping.rb