Class: Seiun::XMLGenerators::BatchXML

Inherits:
Base
  • Object
show all
Defined in:
lib/seiun/xml_generators/batch_xml.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Seiun::XMLGenerators::Base

Class Method Details

.add_batch(records, callback: nil) ⇒ Object



5
6
7
8
# File 'lib/seiun/xml_generators/batch_xml.rb', line 5

def add_batch(records, callback: nil)
  generator = new(callback: callback)
  generator.add_batch(records)
end

Instance Method Details

#add_batch(records) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/seiun/xml_generators/batch_xml.rb', line 11

def add_batch(records)
  sobjects = rexml_doc.add_element("sObjects", 
    "xmlns" => "http://www.force.com/2009/06/asyncapi/dataload",
    "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance")
  records.each do |record|
    add_record(sobjects, record)
  end
  str = to_s
  sobjects = nil
  clear_rexml_doc!
  str
end