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