lib/salesforce/bulk/batch.rb in activeforce-1.7.1 vs lib/salesforce/bulk/batch.rb in activeforce-1.8.0

- old
+ new

@@ -1,5 +1,9 @@ +require 'csv' + +CSVLib = RUBY_VERSION.start_with?("1.8") ? FasterCSV : CSV + module Salesforce module Bulk class Batch Result = Struct.new :id, :success, :created, :error include ::Salesforce::Attributes @@ -9,11 +13,11 @@ include Blockenspiel::DSL def initialize(job) self.job = job self.filename = temporary_csv_file - self.csv = FasterCSV.open(self.filename, 'w+') + self.csv = CSVLib.open(self.filename, 'w+') self.csv << csv_header end def record(record) if record.is_a?(Hash) @@ -61,17 +65,17 @@ end private def parse_csv_results(results) - parsed_results = FasterCSV.parse(results) + parsed_results = CSVLib.parse(results) parsed_results[1..-1].map { |row| Result.new(*row) } end def csv_header self.job.csv_columns.map(&:original_name) end end end -end \ No newline at end of file +end