class EmmyExtends::Savon::Operation

Attributes

globals[R]
httpi[R]
locals[R]
request[R]
response[R]

Public Class Methods

new(httpi, globals, locals) click to toggle source
# File lib/emmy_extends/savon/operation.rb, line 13
def initialize(httpi, globals, locals)
  @httpi = httpi
  @request = httpi.request
  @globals = globals
  @locals = locals
  setup
end

Public Instance Methods

connect() click to toggle source
# File lib/emmy_extends/savon/operation.rb, line 21
def connect
  @httpi.connect
end
setup() click to toggle source
# File lib/emmy_extends/savon/operation.rb, line 40
def setup
  @httpi.on :success do |response, httpi, conn|
    @response = ::Savon::Response.new(response, globals, locals)
    unless @response.soap_fault
      unless @response.http_error
        success!(@response, self, conn)
      else
        error!("HTTP error (#{@response.http.code})", self, conn)
      end
    else
      error!("SOAP error (#{@response.soap_fault.to_s})", self, conn)
    end
  end

  @httpi.on :error do |error, httpi, conn|
    @connection = conn
    error!(error, self, conn)
  end
end
sync() click to toggle source
# File lib/emmy_extends/savon/operation.rb, line 25
def sync
  Fiber.sync do |fiber|
    connect

    on :success do |response, savon, conn|
      fiber.resume response
    end

    on :error do |error, savon, conn|
      # FIXME: TimeoutError separate
      fiber.leave EmmyHttp::ConnectionError, error.to_s
    end
  end
end