Class: Restforce::Bulk::Builder::Xml
- Inherits:
-
Object
- Object
- Restforce::Bulk::Builder::Xml
- Defined in:
- lib/restforce/bulk/builder/xml.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#operation ⇒ Object
Returns the value of attribute operation.
Instance Method Summary collapse
- #abort ⇒ Object
- #close ⇒ Object
- #generate(data) ⇒ Object
-
#initialize(operation) ⇒ Xml
constructor
A new instance of Xml.
- #job(object_name, content_type) ⇒ Object
- #query(data) ⇒ Object
- #transform(data, operation, content_type) ⇒ Object
Constructor Details
#initialize(operation) ⇒ Xml
Returns a new instance of Xml.
7 8 9 |
# File 'lib/restforce/bulk/builder/xml.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/xml.rb', line 5 def operation @operation end |
Instance Method Details
#abort ⇒ Object
25 26 27 28 29 |
# File 'lib/restforce/bulk/builder/xml.rb', line 25 def abort build_xml(:jobInfo) do |xml| xml.state 'Aborted' end end |
#close ⇒ Object
19 20 21 22 23 |
# File 'lib/restforce/bulk/builder/xml.rb', line 19 def close build_xml(:jobInfo) do |xml| xml.state 'Closed' end end |
#generate(data) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/restforce/bulk/builder/xml.rb', line 39 def generate(data) build_xml(:sObjects) do |xml| data.each do |item| xml.sObject do item.each do |attr, value| xml.send(attr, value) end end end end end |
#job(object_name, content_type) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/restforce/bulk/builder/xml.rb', line 11 def job(object_name, content_type) build_xml(:jobInfo) do |xml| xml.operation operation xml.object object_name xml.contentType content_type end end |
#query(data) ⇒ Object
35 36 37 |
# File 'lib/restforce/bulk/builder/xml.rb', line 35 def query(data) data end |
#transform(data, operation, content_type) ⇒ Object
31 32 33 |
# File 'lib/restforce/bulk/builder/xml.rb', line 31 def transform(data, operation, content_type) operation == 'query' ? query(data) : generate(data) end |