class Restforce::Bulk::Builder::Xml
Attributes
operation[RW]
Public Class Methods
new(operation)
click to toggle source
# File lib/restforce/bulk/builder/xml.rb, line 7 def initialize(operation) self.operation = operation end
Public Instance Methods
abort()
click to toggle source
# File lib/restforce/bulk/builder/xml.rb, line 25 def abort build_xml(:jobInfo) do |xml| xml.state 'Aborted' end end
close()
click to toggle source
# File lib/restforce/bulk/builder/xml.rb, line 19 def close build_xml(:jobInfo) do |xml| xml.state 'Closed' end end
generate(data)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# File lib/restforce/bulk/builder/xml.rb, line 35 def query(data) data end
transform(data, operation, content_type)
click to toggle source
# File lib/restforce/bulk/builder/xml.rb, line 31 def transform(data, operation, content_type) operation == 'query' ? query(data) : generate(data) end
Protected Instance Methods
build_xml(root, options={}, &block)
click to toggle source
# File lib/restforce/bulk/builder/xml.rb, line 53 def build_xml(root, options={}, &block) Nokogiri::XML::Builder.new { |xml| xml.send(root, { xmlns: 'http://www.force.com/2009/06/asyncapi/dataload' }.merge(options), &block) }.to_xml(encoding: 'UTF-8') end