FinalCAD/csv_row_model

View on GitHub
lib/csv_row_model/internal/model/dynamic_column_header.rb

Summary

Maintainability
A
0 mins
Test Coverage
require 'csv_row_model/internal/model/header'
require 'csv_row_model/internal/concerns/dynamic_column_shared'

module CsvRowModel
  module Model
    class DynamicColumnHeader < Header
      include DynamicColumnShared

      def value
        header_models.map { |header_model| header_proc.call(header_model) }
      end

      def header_proc
        options[:header] || ->(header_model) { format_header(header_model) }
      end

      def format_header(header_model)
        row_model_class.format_dynamic_column_header(header_model, column_name, context)
      end
    end
  end
end