Module: RForce
- Defined in:
- lib/rforce.rb,
lib/rforce/version.rb,
lib/rforce/method_keys.rb,
lib/rforce/soap_pullable.rb,
lib/rforce/soap_response_expat.rb,
lib/rforce/soap_response_rexml.rb
Defined Under Namespace
Modules: MethodKeys, SoapPullable Classes: MethodHash, SoapResponseExpat, SoapResponseRexml
Constant Summary collapse
- SoapResponse =
parser(:SoapResponseExpat) || parser(:SoapResponseHpricot) || SoapResponseRexml
- VERSION =
'0.3'
Class Method Summary collapse
-
.parser(name) ⇒ Object
Use the fastest XML parser available.
Instance Method Summary collapse
-
#expand(builder, args, xmlns = nil) ⇒ Object
Expand Ruby data structures into XML.
Class Method Details
.parser(name) ⇒ Object
Use the fastest XML parser available.
72 73 74 |
# File 'lib/rforce.rb', line 72 def self.parser(name) RForce.const_get(name) rescue nil end |
Instance Method Details
#expand(builder, args, xmlns = nil) ⇒ Object
Expand Ruby data structures into XML.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/rforce.rb', line 82 def (builder, args, xmlns = nil) # Nest arrays: [:a, 1, :b, 2] => [[:a, 1], [:b, 2]] if (args.class == Array) args.each_index{|i| args[i, 2] = [args[i, 2]]} end args.each do |key, value| attributes = xmlns ? {:xmlns => xmlns} : {} # If the XML tag requires attributes, # the tag name will contain a space # followed by a string representation # of a hash of attributes. # # e.g. 'sObject {"xsi:type" => "Opportunity"}' # becomes <sObject xsi:type="Opportunity>...</sObject> if key.is_a? String key, modifier = key.split(' ', 2) attributes.merge!(eval(modifier)) if modifier end # Create an XML element and fill it with this # value's sub-items. case value when Hash, Array builder.tag!(key, attributes) do builder, value; end when String builder.tag!(key, attributes) { builder.text! value } end end end |