Module: WashOutHelper
- Defined in:
- app/helpers/wash_out_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
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 61 62 |
# File 'app/helpers/wash_out_helper.rb', line 28 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
18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/wash_out_helper.rb', line 18 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 15 16 |
# File 'app/helpers/wash_out_helper.rb', line 3 def (param) case controller.soap_config.wsdl_style when 'rpc' if param.map.present? || !param.value.nil? { :"xsi:type" => param.namespaced_type } else { :"xsi:nil" => true } end when 'document' {} else {} end end |
#wsdl_occurence(param, inject, extend_with = {}) ⇒ Object
104 105 106 107 108 109 110 111 |
# File 'app/helpers/wash_out_helper.rb', line 104 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
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 101 102 |
# File 'app/helpers/wash_out_helper.rb', line 64 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 |