lib/decisive/template_handler.rb in decisive-0.8.0 vs lib/decisive/template_handler.rb in decisive-0.8.1

- old
+ new

@@ -18,11 +18,11 @@ response.headers["Content-Disposition"] = %(attachment; filename="\#{context.filename}") if context.csv? response.headers["Content-Type"] = "text/csv" - if controller.is_a?(ActionController::Live) + if @stream begin context.each do |row| response.stream.write row.to_csv(force_quotes: true) end ensure @@ -53,9 +53,10 @@ end end module DSL def csv records, filename:, stream: true, &block + @stream = stream if stream raise StreamingNotEnabledByControllerError unless controller.is_a?(ActionController::Live) raise StreamIncompatibleBlockArgumentError if block.arity != 0 StreamCSVContext.new(records, filename, block) else