Sha256: e6988aeec6e4a36d79e66a94c6f93bd99b0fceac1db0536958803b73d4eef076

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

module CsvRowModel
  module Import
    class DynamicColumnCell < CsvRowModel::Model::DynamicColumnCell
      attr_reader :source_headers, :source_cells

      def initialize(column_name, source_headers, source_cells, row_model)
        @source_headers = source_headers
        @source_cells = source_cells
        super(column_name, row_model)
      end

      def unformatted_value
        formatted_cells.zip(formatted_headers).map do |formatted_cell, source_header|
          call_process_cell(formatted_cell, source_header)
        end
      end

      def formatted_cells
        source_cells.map.with_index do |source_cell, index|
          row_model.class.format_cell(source_cell, column_name, dynamic_column_index + index, row_model.context)
        end
      end

      def formatted_headers
        source_headers.map.with_index do |source_header, index|
          row_model.class.format_dynamic_column_header(source_header, column_name, dynamic_column_index, index, row_model.context)
        end
      end

      class << self
        def define_process_cell(row_model_class, column_name)
          super { |formatted_cell, source_header| formatted_cell }
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
csv_row_model-1.0.0.beta1 lib/csv_row_model/import/dynamic_column_cell.rb