Skip to content

Commit cd1f271

Browse files
ekzobrainpcai
authored andcommitted
Allow to pass already configured Nori instance and not mess Nori options with Savon options
1 parent a5bdcb9 commit cd1f271

File tree

3 files changed

+12
-21
lines changed

3 files changed

+12
-21
lines changed

lib/savon/operation.rb

-4
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,6 @@ def build_connection(builder)
129129
end
130130
connection.headers["Content-Type"] = (ctype_headers + ["start=\"#{builder.multipart[:start]}\"",
131131
"boundary=\"#{builder.multipart[:multipart_boundary]}\""]).join("; ")
132-
# request.headers["Content-Type"] = ["multipart/related",
133-
# "type=\"#{SOAP_REQUEST_TYPE[@globals[:soap_version]]}\"",
134-
# "start=\"#{builder.multipart[:start]}\"",
135-
# "boundary=\"#{builder.multipart[:multipart_boundary]}\""].join("; ")
136132
connection.headers["MIME-Version"] = "1.0"
137133
end
138134

lib/savon/options.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,9 @@ def response_parser(parser)
495495
@options[:response_parser] = parser
496496
end
497497

498-
# Instruct Nori how to convert empty tags.
499-
def empty_tag_value(empty_tag_value)
500-
@options[:empty_tag_value] = empty_tag_value
498+
# Pass already configured Nori instance.
499+
def nori(nori)
500+
@options[:nori] = nori
501501
end
502502

503503
# Instruct Savon to create a multipart response if available.

lib/savon/response.rb

+9-14
Original file line numberDiff line numberDiff line change
@@ -142,21 +142,16 @@ def xml_namespaces
142142
end
143143

144144
def nori
145-
return @nori if @nori
145+
return @locals[:nori] if @locals[:nori]
146146

147-
nori_options = {
148-
:delete_namespace_attributes => @globals[:delete_namespace_attributes],
149-
:strip_namespaces => @globals[:strip_namespaces],
150-
:convert_tags_to => @globals[:convert_response_tags_to],
151-
:convert_attributes_to => @globals[:convert_attributes_to],
152-
:advanced_typecasting => @locals[:advanced_typecasting],
153-
:parser => @locals[:response_parser],
154-
:empty_tag_value => @locals[:empty_tag_value]
155-
}
156-
157-
non_nil_nori_options = nori_options.reject { |_, value| value.nil? }
158-
@nori = Nori.new(non_nil_nori_options)
147+
@nori ||= Nori.new({
148+
:delete_namespace_attributes => @globals[:delete_namespace_attributes],
149+
:strip_namespaces => @globals[:strip_namespaces],
150+
:convert_tags_to => @globals[:convert_response_tags_to],
151+
:convert_attributes_to => @globals[:convert_attributes_to],
152+
:advanced_typecasting => @locals[:advanced_typecasting],
153+
:parser => @locals[:response_parser]
154+
}.reject { |_, value| value.nil? })
159155
end
160-
161156
end
162157
end

0 commit comments

Comments
 (0)