aboutsummaryrefslogtreecommitdiffstats
path: root/actionwebservice/lib/action_web_service
diff options
context:
space:
mode:
authorKent Sibilev <ksibilev@gmail.com>2007-01-24 20:59:41 +0000
committerKent Sibilev <ksibilev@gmail.com>2007-01-24 20:59:41 +0000
commit5544231caf768d217bcb85842f6d243f3481bd04 (patch)
tree4b0a09530b7b6c583642136b0e1051f98c2a2e70 /actionwebservice/lib/action_web_service
parent6ee09b6a0a548362e8602d56b7db7c03c65512fa (diff)
downloadrails-5544231caf768d217bcb85842f6d243f3481bd04.tar.gz
rails-5544231caf768d217bcb85842f6d243f3481bd04.tar.bz2
rails-5544231caf768d217bcb85842f6d243f3481bd04.zip
Documentation for ActionWebService::API::Base.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6037 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionwebservice/lib/action_web_service')
-rw-r--r--actionwebservice/lib/action_web_service/api.rb49
-rw-r--r--actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb4
2 files changed, 51 insertions, 2 deletions
diff --git a/actionwebservice/lib/action_web_service/api.rb b/actionwebservice/lib/action_web_service/api.rb
index d97eb5e6a1..ccc4b7d656 100644
--- a/actionwebservice/lib/action_web_service/api.rb
+++ b/actionwebservice/lib/action_web_service/api.rb
@@ -98,17 +98,34 @@ module ActionWebService # :nodoc:
end
# Whether the given method name is a service method on this API
+ #
+ # class ProjectsApi < ActionWebService::API::Base
+ # api_method :getCount, :returns => [:int]
+ # end
+ #
+ # ProjectsApi.has_api_method?('GetCount') #=> false
+ # ProjectsApi.has_api_method?(:getCount) #=> true
def has_api_method?(name)
api_methods.has_key?(name)
end
# Whether the given public method name has a corresponding service method
# on this API
+ #
+ # class ProjectsApi < ActionWebService::API::Base
+ # api_method :getCount, :returns => [:int]
+ # end
+ #
+ # ProjectsApi.has_api_method?(:getCount) #=> false
+ # ProjectsApi.has_api_method?('GetCount') #=> true
def has_public_api_method?(public_name)
api_public_method_names.has_key?(public_name)
end
# The corresponding public method name for the given service method name
+ #
+ # ProjectsApi.public_api_method_name('GetCount') #=> "GetCount"
+ # ProjectsApi.public_api_method_name(:getCount) #=> "GetCount"
def public_api_method_name(name)
if inflect_names
name.to_s.camelize
@@ -118,22 +135,54 @@ module ActionWebService # :nodoc:
end
# The corresponding service method name for the given public method name
+ #
+ # class ProjectsApi < ActionWebService::API::Base
+ # api_method :getCount, :returns => [:int]
+ # end
+ #
+ # ProjectsApi.api_method_name('GetCount') #=> :getCount
def api_method_name(public_name)
api_public_method_names[public_name]
end
# A Hash containing all service methods on this API, and their
# associated metadata.
+ #
+ # class ProjectsApi < ActionWebService::API::Base
+ # api_method :getCount, :returns => [:int]
+ # api_method :getCompletedCount, :returns => [:int]
+ # end
+ #
+ # ProjectsApi.api_methods #=>
+ # {:getCount=>#<ActionWebService::API::Method:0x24379d8 ...>,
+ # :getCompletedCount=>#<ActionWebService::API::Method:0x2437794 ...>}
+ # ProjectsApi.api_methods[:getCount].public_name #=> "GetCount"
def api_methods
read_inheritable_attribute("api_methods") || {}
end
# The Method instance for the given public API method name, if any
+ #
+ # class ProjectsApi < ActionWebService::API::Base
+ # api_method :getCount, :returns => [:int]
+ # api_method :getCompletedCount, :returns => [:int]
+ # end
+ #
+ # ProjectsApi.public_api_method_instance('GetCount') #=> <#<ActionWebService::API::Method:0x24379d8 ...>
+ # ProjectsApi.public_api_method_instance(:getCount) #=> nil
def public_api_method_instance(public_method_name)
api_method_instance(api_method_name(public_method_name))
end
# The Method instance for the given API method name, if any
+ #
+ # class ProjectsApi < ActionWebService::API::Base
+ # api_method :getCount, :returns => [:int]
+ # api_method :getCompletedCount, :returns => [:int]
+ # end
+ #
+ # ProjectsApi.api_method_instance(:getCount) #=> <ActionWebService::API::Method:0x24379d8 ...>
+ # ProjectsApi.api_method_instance('GetCount') #=> <ActionWebService::API::Method:0x24379d8 ...>
def api_method_instance(method_name)
api_methods[method_name]
end
diff --git a/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb b/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb
index 9c16c50248..f240dbe904 100644
--- a/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb
+++ b/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb
@@ -38,8 +38,8 @@ module ActionWebService # :nodoc:
private
def dispatch_web_service_request
method = request.method.to_s.upcase
- allowed_methods = self.class.web_service_api ? (self.class.web_service_api.allowed_http_methods.dup || []) : [ :post ]
- allowed_methods.map!{|m| m.to_s.upcase }
+ allowed_methods = self.class.web_service_api ? (self.class.web_service_api.allowed_http_methods || []) : [ :post ]
+ allowed_methods = allowed_methods.map{|m| m.to_s.upcase }
if !allowed_methods.include?(method)
render_text("#{method} not supported", "500 #{method} not supported")
return