aboutsummaryrefslogblamecommitdiffstats
path: root/actionwebservice/lib/action_web_service/client/base.rb
blob: 9dada7bf98f45bdf0800367a47355779cbd8b8f5 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
                                 












                                                   
                                                

         





                                                      




             
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?
        self.perform_invocation(call_name, args)
      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
          end
        end
    end
  end
end