aboutsummaryrefslogtreecommitdiffstats
path: root/actionwebservice/lib/action_web_service/client/base.rb
diff options
context:
space:
mode:
authorLeon Breedt <bitserf@gmail.com>2005-02-18 23:55:29 +0000
committerLeon Breedt <bitserf@gmail.com>2005-02-18 23:55:29 +0000
commitec03a601811587dd4265667aadd50c101c23b116 (patch)
treeb040f5f1488267b35bc0110efe029a789c3a350b /actionwebservice/lib/action_web_service/client/base.rb
parent5760a6cb3e3f3ce3b41c25023f3fbb875590c5bc (diff)
downloadrails-ec03a601811587dd4265667aadd50c101c23b116.tar.gz
rails-ec03a601811587dd4265667aadd50c101c23b116.tar.bz2
rails-ec03a601811587dd4265667aadd50c101c23b116.zip
rename entire package to Action Web Service
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@672 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionwebservice/lib/action_web_service/client/base.rb')
-rw-r--r--actionwebservice/lib/action_web_service/client/base.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/actionwebservice/lib/action_web_service/client/base.rb b/actionwebservice/lib/action_web_service/client/base.rb
new file mode 100644
index 0000000000..d01cffcd56
--- /dev/null
+++ b/actionwebservice/lib/action_web_service/client/base.rb
@@ -0,0 +1,35 @@
+module ActionWebService # :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