Class: Restforce::Bulk::Builder::Csv
- Inherits:
-
Object
- Object
- Restforce::Bulk::Builder::Csv
- Defined in:
- lib/restforce/bulk/builder/csv.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#operation ⇒ Object
Returns the value of attribute operation.
Instance Method Summary collapse
- #generate(data) ⇒ Object
-
#initialize(operation) ⇒ Csv
constructor
A new instance of Csv.
- #query(data) ⇒ Object
- #transform(data, operation, content_type) ⇒ Object
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
#operation ⇒ Object
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 |