Sha256: 5b0d3ab1221807157da0d1a7714d8913596a3860aca75f8b9a00f5a604315f55

Contents?: true

Size: 957 Bytes

Versions: 8

Compression:

Stored size: 957 Bytes

Contents

# frozen_string_literal: true

module Lite
  module Report
    module Helpers
      module Transporters

        private

        def generate_export!
          CSV.generate(**@csv_options) do |csv|
            @data.each do |row|
              csv << process_export_row!(row)
            end
          end
        end

        def generate_or_stream_export!
          return stream_export! if stream?(delete: true)

          generate_export!
        end

        def stream?(delete: false)
          return @csv_options.delete(:stream) if delete

          @csv_options[:stream]
        end

        def stream_export!
          Enumerator.new do |csv|
            csv << CSV.generate_line(headers?(delete: true)) if write_headers?(delete: true)

            @data.each do |row|
              row = process_export_row!(row)
              csv << CSV.generate_line(row, **@csv_options)
            end
          end
        end

      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
lite-report-1.3.2 lib/lite/report/helpers/transporters.rb
lite-report-1.3.1 lib/lite/report/helpers/transporters.rb
lite-report-1.3.0 lib/lite/report/helpers/transporters.rb
lite-report-1.2.0 lib/lite/report/helpers/transporters.rb
lite-report-1.1.1 lib/lite/report/helpers/transporters.rb
lite-report-1.1.0 lib/lite/report/helpers/transporters.rb
lite-report-1.0.6 lib/lite/report/helpers/transporters.rb
lite-report-1.0.5 lib/lite/report/helpers/transporters.rb