Skip to content

Commit

Permalink
Merge pull request #673 from TiteiKo/master
Browse files Browse the repository at this point in the history
closes #672 add unwrap option and pass it to Gyoku
  • Loading branch information
tjarratt committed Mar 11, 2015
2 parents 217a4b7 + 81f3fe6 commit fba39c6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
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

0 comments on commit fba39c6

Please sign in to comment.