Skip to content

Commit

Permalink
Allow to pass already configured Nori instance and not mess Nori opti…
Browse files Browse the repository at this point in the history
…ons with Savon options
  • Loading branch information
ekzobrain authored and pcai committed Jul 15, 2024
1 parent a5bdcb9 commit cd1f271
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
4 changes: 0 additions & 4 deletions lib/savon/operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ def build_connection(builder)
end
connection.headers["Content-Type"] = (ctype_headers + ["start=\"#{builder.multipart[:start]}\"",
"boundary=\"#{builder.multipart[:multipart_boundary]}\""]).join("; ")
# request.headers["Content-Type"] = ["multipart/related",
# "type=\"#{SOAP_REQUEST_TYPE[@globals[:soap_version]]}\"",
# "start=\"#{builder.multipart[:start]}\"",
# "boundary=\"#{builder.multipart[:multipart_boundary]}\""].join("; ")
connection.headers["MIME-Version"] = "1.0"
end

Expand Down
6 changes: 3 additions & 3 deletions lib/savon/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,9 @@ def response_parser(parser)
@options[:response_parser] = parser
end

# Instruct Nori how to convert empty tags.
def empty_tag_value(empty_tag_value)
@options[:empty_tag_value] = empty_tag_value
# Pass already configured Nori instance.
def nori(nori)
@options[:nori] = nori
end

# Instruct Savon to create a multipart response if available.
Expand Down
23 changes: 9 additions & 14 deletions lib/savon/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,16 @@ def xml_namespaces
end

def nori
return @nori if @nori
return @locals[:nori] if @locals[:nori]

nori_options = {
:delete_namespace_attributes => @globals[:delete_namespace_attributes],
:strip_namespaces => @globals[:strip_namespaces],
:convert_tags_to => @globals[:convert_response_tags_to],
:convert_attributes_to => @globals[:convert_attributes_to],
:advanced_typecasting => @locals[:advanced_typecasting],
:parser => @locals[:response_parser],
:empty_tag_value => @locals[:empty_tag_value]
}

non_nil_nori_options = nori_options.reject { |_, value| value.nil? }
@nori = Nori.new(non_nil_nori_options)
@nori ||= Nori.new({
:delete_namespace_attributes => @globals[:delete_namespace_attributes],
:strip_namespaces => @globals[:strip_namespaces],
:convert_tags_to => @globals[:convert_response_tags_to],
:convert_attributes_to => @globals[:convert_attributes_to],
:advanced_typecasting => @locals[:advanced_typecasting],
:parser => @locals[:response_parser]
}.reject { |_, value| value.nil? })
end

end
end

0 comments on commit cd1f271

Please sign in to comment.