aboutsummaryrefslogtreecommitdiffstats
path: root/actionwebservice/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionwebservice/lib')
-rw-r--r--actionwebservice/lib/action_web_service/casting.rb13
-rw-r--r--actionwebservice/lib/action_web_service/struct.rb4
-rw-r--r--actionwebservice/lib/action_web_service/test_invoke.rb10
3 files changed, 16 insertions, 11 deletions
diff --git a/actionwebservice/lib/action_web_service/casting.rb b/actionwebservice/lib/action_web_service/casting.rb
index 113b24a93c..42ef97fd3b 100644
--- a/actionwebservice/lib/action_web_service/casting.rb
+++ b/actionwebservice/lib/action_web_service/casting.rb
@@ -40,7 +40,7 @@ module ActionWebService # :nodoc:
def cast(value, signature_type) # :nodoc:
return value if signature_type.nil? # signature.length != params.length
- unless signature_type.array?
+ unless signature_type.array? || signature_type.structured?
return value if canonical_type(value.class) == signature_type.type
end
if signature_type.array?
@@ -86,13 +86,20 @@ module ActionWebService # :nodoc:
end
def cast_to_structured_type(value, signature_type) # :nodoc:
- obj = signature_type.type_class.new
+ obj = nil
+ obj = value if canonical_type(value.class) == canonical_type(signature_type.type)
+ obj ||= signature_type.type_class.new
if value.respond_to?(:each_pair)
klass = signature_type.type_class
value.each_pair do |name, val|
type = klass.respond_to?(:member_type) ? klass.member_type(name) : nil
val = cast(val, type) if type
- obj.send("#{name}=", val)
+ obj.__send__("#{name}=", val)
+ end
+ elsif value.respond_to?(:attributes)
+ signature_type.each_member do |name, type|
+ val = value.__send__(name)
+ obj.__send__("#{name}=", cast(val, type))
end
else
raise CastingError, "Don't know how to cast #{value.class} to #{signature_type.type_class}"
diff --git a/actionwebservice/lib/action_web_service/struct.rb b/actionwebservice/lib/action_web_service/struct.rb
index f2bfba9e30..536207aa95 100644
--- a/actionwebservice/lib/action_web_service/struct.rb
+++ b/actionwebservice/lib/action_web_service/struct.rb
@@ -24,7 +24,7 @@ module ActionWebService
# it can contain initial values for the structure member.
def initialize(values={})
if values.is_a?(Hash)
- values.map{|k,v| send('%s=' % k.to_s, v)}
+ values.map{|k,v| __send__('%s=' % k.to_s, v)}
end
end
@@ -36,7 +36,7 @@ module ActionWebService
# Iterates through each member
def each_pair(&block)
self.class.members.each do |name, type|
- yield name, type
+ yield name, self.__send__(name)
end
end
diff --git a/actionwebservice/lib/action_web_service/test_invoke.rb b/actionwebservice/lib/action_web_service/test_invoke.rb
index c22ca618dc..119bc21f68 100644
--- a/actionwebservice/lib/action_web_service/test_invoke.rb
+++ b/actionwebservice/lib/action_web_service/test_invoke.rb
@@ -59,10 +59,8 @@ module Test # :nodoc:
def decode_rpc_response
public_method_name, return_value = protocol.decode_response(@response.body)
- unless @return_exceptions
- exception = is_exception?(return_value)
- raise exception if exception
- end
+ exception = is_exception?(return_value)
+ raise exception if exception
return_value
end
@@ -90,10 +88,10 @@ module Test # :nodoc:
def is_exception?(obj)
case protocol
- when :soap
+ when :soap, ActionWebService::Protocol::Soap::SoapProtocol
(obj.respond_to?(:detail) && obj.detail.respond_to?(:cause) && \
obj.detail.cause.is_a?(Exception)) ? obj.detail.cause : nil
- when :xmlrpc
+ when :xmlrpc, ActionWebService::Protocol::XmlRpc::XmlRpcProtocol
obj.is_a?(XMLRPC::FaultException) ? obj : nil
end
end