Sha256: 44e3be9a485f0f49c2eca6fa0e7c732e034faf332958bd3d5c91715ee8fa3b47

Contents?: true

Size: 514 Bytes

Versions: 13

Compression:

Stored size: 514 Bytes

Contents

module PipeRpc
  class Client::Request
    class Response
      def initialize(hub, body)
        @hub = hub
        @body = body
      end

      attr_reader :body

      def result?
        @body.has_key? :result
      end

      def error?
        @body.has_key? :error
      end

      def handle
        type = result? ? ResultResponse : ErrorResponse
        result = type.new(@hub.requests[@body[:id]], @body).to_result
        @hub.requests.inject_result_for(@body[:id], result)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
pipe_rpc-2.5.0 lib/pipe_rpc/client_request_response.rb
pipe_rpc-2.4.0 lib/pipe_rpc/client_request_response.rb
pipe_rpc-2.3.0 lib/pipe_rpc/client_request_response.rb
pipe_rpc-2.2.3 lib/pipe_rpc/client_request_response.rb
pipe_rpc-2.2.2 lib/pipe_rpc/client_request_response.rb
pipe_rpc-2.2.1 lib/pipe_rpc/client_request_response.rb
pipe_rpc-2.2.0 lib/pipe_rpc/client_request_response.rb
pipe_rpc-2.1.0 lib/pipe_rpc/client_request_response.rb
pipe_rpc-2.0.0 lib/pipe_rpc/client_request_response.rb
pipe_rpc-1.1.2 lib/pipe_rpc/client_request_response.rb
pipe_rpc-1.1.1 lib/pipe_rpc/client_request_response.rb
pipe_rpc-1.1.0 lib/pipe_rpc/client_request_response.rb
pipe_rpc-1.0.0 lib/pipe_rpc/client_request_response.rb