@@ -65,20 +65,24 @@ def available_tasks
6565 # Make this Task a task that handles CSV.
6666 #
6767 # @param in_batches [Integer] optionally, supply a batch size if the CSV
68- # should be processed in batches.
68+ # should be processed in batches.
69+ # @param csv_options [Hash] optionally, supply options for the CSV parser.
70+ # If not given, defaults to: <code>{ headers: true }</code>
71+ # @see https://ruby-doc.org/3.3.0/stdlibs/csv/CSV.html#class-CSV-label-Options+for+Parsing
6972 #
7073 # An input to upload a CSV will be added in the form to start a Run. The
7174 # collection and count method are implemented.
72- def csv_collection ( in_batches : nil )
75+ def csv_collection ( in_batches : nil , ** csv_options )
7376 unless defined? ( ActiveStorage )
7477 raise NotImplementedError , "Active Storage needs to be installed\n " \
7578 "To resolve this issue run: bin/rails active_storage:install"
7679 end
7780
81+ csv_options [ :headers ] = true unless csv_options . key? ( :headers )
7882 self . collection_builder_strategy = if in_batches
79- BatchCsvCollectionBuilder . new ( in_batches )
83+ BatchCsvCollectionBuilder . new ( in_batches , ** csv_options )
8084 else
81- CsvCollectionBuilder . new
85+ CsvCollectionBuilder . new ( ** csv_options )
8286 end
8387 end
8488
0 commit comments