Module: WashOutForkHelper
- Defined in:
- app/helpers/wash_out_fork_helper.rb
Instance Method Summary collapse
- #wsdl_data(xml, params) ⇒ Object
- #wsdl_data_attrs(param) ⇒ Object
- #wsdl_data_options(param) ⇒ Object
- #wsdl_occurence(param, inject, extend_with = {}) ⇒ Object
- #wsdl_type(xml, param, defined = []) ⇒ Object
Instance Method Details
#wsdl_data(xml, params) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/helpers/wash_out_fork_helper.rb', line 26 def wsdl_data(xml, params) params.each do |param| next if param.attribute? tag_name = param.name = (param) .merge! wsdl_data_attrs(param) if param.struct? if param.multiplied param.map.each do |p| attrs = wsdl_data_attrs p if p.is_a?(Array) || p.map.size > attrs.size blk = proc { wsdl_data(xml, p.map) } end attrs.reject! { |_, v| v.nil? } xml.tag! tag_name, .merge(attrs), &blk end else xml.tag! tag_name, do wsdl_data(xml, param.map) end end else if param.multiplied param.value = [] unless param.value.is_a?(Array) param.value.each do |v| xml.tag! tag_name, v, end else xml.tag! tag_name, param.value, end end end end |
#wsdl_data_attrs(param) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'app/helpers/wash_out_fork_helper.rb', line 16 def wsdl_data_attrs(param) param.map.reduce({}) do |memo, p| if p.respond_to?(:attribute?) && p.attribute? memo.merge p.attr_name => p.value else memo end end end |
#wsdl_data_options(param) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/helpers/wash_out_fork_helper.rb', line 3 def (param) case controller.soap_config.wsdl_style when 'rpc' if param.map.present? || param.value { :"xsi:type" => param.namespaced_type } else { :"xsi:nil" => true } end when 'document' { } end end |
#wsdl_occurence(param, inject, extend_with = {}) ⇒ Object
102 103 104 105 106 107 108 109 |
# File 'app/helpers/wash_out_fork_helper.rb', line 102 def wsdl_occurence(param, inject, extend_with = {}) data = {"#{'xsi:' if inject}nillable" => 'true'} if param.multiplied data["#{'xsi:' if inject}minOccurs"] = 0 data["#{'xsi:' if inject}maxOccurs"] = 'unbounded' end extend_with.merge(data) end |
#wsdl_type(xml, param, defined = []) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'app/helpers/wash_out_fork_helper.rb', line 62 def wsdl_type(xml, param, defined=[]) more = [] if param.struct? if !defined.include?(param.basic_type) xml.tag! "xsd:complexType", :name => param.basic_type do attrs, elems = [], [] param.map.each do |value| more << value if value.struct? if value.attribute? attrs << value else elems << value end end if elems.any? xml.tag! "xsd:sequence" do elems.each do |value| xml.tag! "xsd:element", wsdl_occurence(value, false, :name => value.name, :type => value.namespaced_type) end end end attrs.each do |value| xml.tag! "xsd:attribute", wsdl_occurence(value, false, :name => value.attr_name, :type => value.namespaced_type) end end defined << param.basic_type elsif !param.classified? raise RuntimeError, "Duplicate use of `#{param.basic_type}` type name. Consider using classified types." end end more.each do |p| wsdl_type xml, p, defined end end |