Class: Savon::Operation
- Inherits:
-
Object
- Object
- Savon::Operation
- Defined in:
- lib/savon/operation.rb
Class Method Summary collapse
- .create(operation_name, wsdl, globals) ⇒ Object
- .ensure_exists!(operation_name, wsdl) ⇒ Object
- .ensure_name_is_symbol!(operation_name) ⇒ Object
Instance Method Summary collapse
- #build(locals = {}, &block) ⇒ Object
- #call(locals = {}, &block) ⇒ Object
-
#initialize(name, wsdl, globals) ⇒ Operation
constructor
A new instance of Operation.
- #request(locals = {}, &block) ⇒ Object
Constructor Details
#initialize(name, wsdl, globals) ⇒ Operation
Returns a new instance of Operation.
37 38 39 40 41 42 43 |
# File 'lib/savon/operation.rb', line 37 def initialize(name, wsdl, globals) @name = name @wsdl = wsdl @globals = globals @logger = RequestLogger.new(globals) end |
Class Method Details
.create(operation_name, wsdl, globals) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/savon/operation.rb', line 12 def self.create(operation_name, wsdl, globals) if wsdl.document? ensure_name_is_symbol! operation_name ensure_exists! operation_name, wsdl end new(operation_name, wsdl, globals) end |
.ensure_exists!(operation_name, wsdl) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/savon/operation.rb', line 21 def self.ensure_exists!(operation_name, wsdl) unless wsdl.soap_actions.include? operation_name raise UnknownOperationError, "Unable to find SOAP operation: #{operation_name.inspect}\n" \ "Operations provided by your service: #{wsdl.soap_actions.inspect}" end rescue Wasabi::Resolver::HTTPError => e raise HTTPError.new(e.response) end |
.ensure_name_is_symbol!(operation_name) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/savon/operation.rb', line 30 def self.ensure_name_is_symbol!(operation_name) unless operation_name.kind_of? Symbol raise ArgumentError, "Expected the first parameter (the name of the operation to call) to be a symbol\n" \ "Actual: #{operation_name.inspect} (#{operation_name.class})" end end |
Instance Method Details
#build(locals = {}, &block) ⇒ Object
45 46 47 48 |
# File 'lib/savon/operation.rb', line 45 def build(locals = {}, &block) set_locals(locals, block) Builder.new(@name, @wsdl, @globals, @locals) end |
#call(locals = {}, &block) ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/savon/operation.rb', line 50 def call(locals = {}, &block) builder = build(locals, &block) response = Savon.notify_observers(@name, builder, @globals, @locals) response ||= call_with_logging build_request(builder) raise_expected_httpi_response! unless response.kind_of?(HTTPI::Response) create_response(response) end |
#request(locals = {}, &block) ⇒ Object
61 62 63 64 |
# File 'lib/savon/operation.rb', line 61 def request(locals = {}, &block) builder = build(locals, &block) build_request(builder) end |