From e7a29380292902eae4799b2658507b3cfffb9cec Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 18 Feb 2005 10:35:25 +0000 Subject: Added Action Service to the repository git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@658 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionservice/lib/action_service/client/base.rb | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 actionservice/lib/action_service/client/base.rb (limited to 'actionservice/lib/action_service/client/base.rb') diff --git a/actionservice/lib/action_service/client/base.rb b/actionservice/lib/action_service/client/base.rb new file mode 100644 index 0000000000..955887a4d8 --- /dev/null +++ b/actionservice/lib/action_service/client/base.rb @@ -0,0 +1,35 @@ +module ActionService # :nodoc: + module Client # :nodoc: + class ClientError < StandardError # :nodoc: + end + + class Base # :nodoc: + def initialize(api, endpoint_uri) + @api = api + @endpoint_uri = endpoint_uri + end + + def method_missing(name, *args) # :nodoc: + call_name = method_name(name) + return super(name, *args) if call_name.nil? + perform_invocation(call_name, args) + end + + protected + def perform_invocation(method_name, args) # :nodoc: + raise NotImplementedError, "use a protocol-specific client" + end + + private + def method_name(name) + if @api.has_api_method?(name.to_sym) + name.to_s + elsif @api.has_public_api_method?(name.to_s) + @api.api_method_name(name.to_s).to_s + else + nil + end + end + end + end +end -- cgit v1.2.3