Sha256: 84f468e520ba28498978002eb2d9ad0f00f3a694fcd70db91fed3cde59cc6f53
Contents?: true
Size: 1.15 KB
Versions: 6
Compression:
Stored size: 1.15 KB
Contents
module CsvRowModel module Export module FileModel extend ActiveSupport::Concern # @return [Array] an array of rows, where if cell is row_name, it's parsed into the header_match # and everything else is return as is. def to_rows rows_template.map do |row| [].tap do |result| row.each do |cell| if header? cell result << self.class.format_header(cell, context) else result << cell.to_s end end end end end # Safe to override # # @return [Array<Array>] an array of arrays, where every represents a row and every row # can have strings and row_name (column_name). By default, # returns a row_name for every row def rows_template @rows_template ||= self.class.row_names.map { |row_name| [row_name] } end class_methods do def setup(csv, context, with_headers: true); end end private def header?(cell) self.class.is_row_name? cell end end end end
Version data entries
6 entries across 6 versions & 1 rubygems