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
- #call(locals = {}, &block) ⇒ Object
-
#initialize(name, wsdl, globals) ⇒ Operation
constructor
A new instance of Operation.
Constructor Details
#initialize(name, wsdl, globals) ⇒ Operation
Returns a new instance of Operation.
32 33 34 35 36 |
# File 'lib/savon/operation.rb', line 32 def initialize(name, wsdl, globals) @name = name @wsdl = wsdl @globals = globals end |
Class Method Details
.create(operation_name, wsdl, globals) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/savon/operation.rb', line 9 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
18 19 20 21 22 23 |
# File 'lib/savon/operation.rb', line 18 def self.ensure_exists!(operation_name, wsdl) unless wsdl.soap_actions.include? operation_name raise ArgumentError, "Unable to find SOAP operation: #{operation_name.inspect}\n" \ "Operations provided by your service: #{wsdl.soap_actions.inspect}" end end |
.ensure_name_is_symbol!(operation_name) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/savon/operation.rb', line 25 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
#call(locals = {}, &block) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/savon/operation.rb', line 38 def call(locals = {}, &block) @locals = LocalOptions.new(locals) BlockInterface.new(@locals).evaluate(block) if block builder = Builder.new(@name, @wsdl, @globals, @locals) request = Request.new(@name, @wsdl, @globals, @locals) response = Savon.notify_observers(@name, builder, @globals, @locals) response ||= request.call(builder.to_s) raise_expected_httpi_response! unless response.kind_of?(HTTPI::Response) Response.new(response, @globals, @locals) end |