lib/rocket_job/sliced/writer/input.rb in rocketjob-4.2.0 vs lib/rocket_job/sliced/writer/input.rb in rocketjob-4.3.0.beta
- old
+ new
@@ -10,19 +10,13 @@
# Parameters
# on_first: [Proc]
# Block to call on the first line only, instead of storing in the slice.
# Useful for extracting the header row
# Default: nil
- def self.collect(input, **args, &block)
+ def self.collect(input, **args)
writer = new(input, **args)
- # Create indexes before uploading
- input.create_indexes if input.respond_to?(:create_indexes)
- block.call(writer)
+ yield(writer)
writer.record_count
- rescue Exception => exc
- # Drop input collection when upload fails
- input.drop
- raise exc
ensure
writer&.close
end
def initialize(input, on_first: nil)