diff options
author | Leon Breedt <bitserf@gmail.com> | 2005-04-05 16:00:28 +0000 |
---|---|---|
committer | Leon Breedt <bitserf@gmail.com> | 2005-04-05 16:00:28 +0000 |
commit | 9b42cd8cc1d52e5a8d80b67b17e5887c15e90904 (patch) | |
tree | 3e79247e7ca3b2bcabf17c38ae48412565b5ca68 /actionwebservice | |
parent | 7a5bac1de0c6a851d5e2a224629ee0a135db6bc2 (diff) | |
download | rails-9b42cd8cc1d52e5a8d80b67b17e5887c15e90904.tar.gz rails-9b42cd8cc1d52e5a8d80b67b17e5887c15e90904.tar.bz2 rails-9b42cd8cc1d52e5a8d80b67b17e5887c15e90904.zip |
add API::Method#expects_to_hash convenience as well
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1092 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionwebservice')
-rw-r--r-- | actionwebservice/lib/action_web_service/api.rb | 9 | ||||
-rw-r--r-- | actionwebservice/test/api_test.rb | 6 |
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 |