Class: Restforce::Bulk::Builder::Xml

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

Direct Known Subclasses

ZipXml

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#operationObject

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

#abortObject



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

#closeObject



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