Sha256: 831d5f7be3c72f13d67f47262c6681281d1ea553342217d13911109ac8a36f1c

Contents?: true

Size: 934 Bytes

Versions: 4

Compression:

Stored size: 934 Bytes

Contents

module PipeRpc
  class Hub::Responder
    class Request
      def initialize(responder, request)
        @responder, @request = responder, request
      end

      def id
        @request.id
      end

      CALL_FILE, CALL_LINENO = __FILE__, __LINE__+3
      def handle
        evaluate_result do
          @responder.servers[@request.server].__send__(@request.method, *@request.arguments, &evaluate_result_proc)
        end
      end

      def evaluate_result(result = nil, &block)
        result = Result.new(self, block_given? ? yield : result)
      rescue Exception => e
        result = ErrorResult.new(@request, e)
      ensure
        @responder.send_response(result.to_response) unless result.asynchronous?
        return result.value
      end

      def evaluate_result_proc
        @evaluate_result_proc ||= proc do |result = nil, &block|
          evaluate_result(result, &block)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pipe_rpc-0.3.2 lib/pipe_rpc/hub/responder/request.rb
pipe_rpc-0.3.1 lib/pipe_rpc/hub/responder/request.rb
pipe_rpc-0.3.0 lib/pipe_rpc/hub/responder/request.rb
pipe_rpc-0.2.2 lib/pipe_rpc/hub/responder/request.rb