aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionwebservice/lib/action_web_service/api.rb9
-rw-r--r--actionwebservice/test/api_test.rb6
2 files changed, 15 insertions, 0 deletions
diff --git a/actionwebservice/lib/action_web_service/api.rb b/actionwebservice/lib/action_web_service/api.rb
index edc2ff17f4..0ff1671144 100644
--- a/actionwebservice/lib/action_web_service/api.rb
+++ b/actionwebservice/lib/action_web_service/api.rb
@@ -192,6 +192,15 @@ module ActionWebService # :nodoc:
-1
end
+ # Returns a hash keyed by parameter name for the given
+ # parameter list
+ def expects_to_hash(params)
+ return {} if @expects.nil?
+ h = {}
+ @expects.zip(params){ |type, param| h[type.name] = param }
+ h
+ end
+
# String representation of this method
def to_s
fqn = ""
diff --git a/actionwebservice/test/api_test.rb b/actionwebservice/test/api_test.rb
index 986df47a14..2278a8213e 100644
--- a/actionwebservice/test/api_test.rb
+++ b/actionwebservice/test/api_test.rb
@@ -85,6 +85,12 @@ class TC_API < Test::Unit::TestCase
assert_equal -1, API.api_methods[:void].expects_index_of('test')
end
+ def test_parameter_hash
+ method = API.api_methods[:named_signature]
+ hash = method.expects_to_hash([5, false])
+ assert_equal({:appkey => 5, :publish => false}, hash)
+ end
+
def test_to_s
assert_equal 'void Expects(int param0, bool param1)', APITest::API.api_methods[:expects].to_s
end