Went through the specs and updated them to reflect the application
[lyrix.git] / vendor / rails / actionwebservice / lib / action_web_service / protocol / discovery.rb
blob3d4e0818daa54db3a921c59abb6c4f8d43fe1ffa
1 module ActionWebService # :nodoc:
2   module Protocol # :nodoc:
3     module Discovery # :nodoc:
4       def self.included(base)
5         base.extend(ClassMethods)
6         base.send(:include, ActionWebService::Protocol::Discovery::InstanceMethods)
7       end
9       module ClassMethods # :nodoc:
10         def register_protocol(klass)
11           write_inheritable_array("web_service_protocols", [klass])
12         end
13       end
15       module InstanceMethods # :nodoc:
16         private
17           def discover_web_service_request(action_pack_request)
18             (self.class.read_inheritable_attribute("web_service_protocols") || []).each do |protocol|
19               protocol = protocol.create(self)
20               request = protocol.decode_action_pack_request(action_pack_request)
21               return request unless request.nil?
22             end
23             nil
24           end
26           def create_web_service_client(api, protocol_name, endpoint_uri, options)
27             (self.class.read_inheritable_attribute("web_service_protocols") || []).each do |protocol|
28               protocol = protocol.create(self)
29               client = protocol.protocol_client(api, protocol_name, endpoint_uri, options)
30               return client unless client.nil?
31             end
32             nil
33           end
34       end
35     end
36   end
37 end