Class: Restforce::Bulk::Builder::Csv

Inherits:
Object
  • Object
show all
Defined in:
lib/restforce/bulk/builder/csv.rb

Direct Known Subclasses

ZipCsv

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operation) ⇒ Csv

Returns a new instance of Csv.



7
8
9
# File 'lib/restforce/bulk/builder/csv.rb', line 7

def initialize(operation)
  self.operation = operation
end

Instance Attribute Details

#operationObject

Returns the value of attribute operation.



5
6
7
# File 'lib/restforce/bulk/builder/csv.rb', line 5

def operation
  @operation
end

Instance Method Details

#generate(data) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/restforce/bulk/builder/csv.rb', line 19

def generate(data)
  ::CSV.generate do |csv|
    csv << data.first.keys

    data.each do |attributes|
      csv << attributes.values
    end
  end
end

#query(data) ⇒ Object



15
16
17
# File 'lib/restforce/bulk/builder/csv.rb', line 15

def query(data)
  data
end

#transform(data, operation, content_type) ⇒ Object



11
12
13
# File 'lib/restforce/bulk/builder/csv.rb', line 11

def transform(data, operation, content_type)
  operation == 'query' ? query(data) : generate(data)
end