Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

closes #672 add unwrap option and pass it to Gyoku #673

Merged
merged 1 commit into from
Mar 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/savon/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def message
element_form_default = @globals[:element_form_default] || @wsdl.element_form_default
# TODO: clean this up! [dh, 2012-12-17]
Message.new(message_tag, namespace_identifier, @types, @used_namespaces, @locals[:message],
element_form_default, @globals[:convert_request_keys_to])
element_form_default, @globals[:convert_request_keys_to], @globals[:unwrap])
end

def namespace_identifier
Expand Down
6 changes: 4 additions & 2 deletions lib/savon/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
module Savon
class Message

def initialize(message_tag, namespace_identifier, types, used_namespaces, message, element_form_default, key_converter)
def initialize(message_tag, namespace_identifier, types, used_namespaces, message, element_form_default, key_converter, unwrap)
@message_tag = message_tag
@namespace_identifier = namespace_identifier
@types = types
Expand All @@ -13,6 +13,7 @@ def initialize(message_tag, namespace_identifier, types, used_namespaces, messag
@message = message
@element_form_default = element_form_default
@key_converter = key_converter
@unwrap = unwrap
end

def to_s
Expand All @@ -25,7 +26,8 @@ def to_s
gyoku_options = {
:element_form_default => @element_form_default,
:namespace => @namespace_identifier,
:key_converter => @key_converter
:key_converter => @key_converter,
:unwrap => @unwrap
}

Gyoku.xml(@message, gyoku_options)
Expand Down
7 changes: 7 additions & 0 deletions lib/savon/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def initialize(options = {})
:use_wsa_headers => false,
:no_message_tag => false,
:follow_redirects => false,
:unwrap => false
}

options = defaults.merge(options)
Expand Down Expand Up @@ -287,6 +288,12 @@ def convert_request_keys_to(converter)
@options[:convert_request_keys_to] = converter
end

# Tell Gyoku to unwrap Array of Hashes
# Accepts a boolean, default to false
def unwrap(unwrap)
@options[:unwrap] = unwrap
end

# Tell Nori how to convert XML tags from the SOAP response into Hash keys.
# Accepts a lambda or a block which receives an XML tag and returns a Hash key.
# Defaults to convert tags to snakecase Symbols.
Expand Down