Sha256: 37289de8828e1a8f88f99c3af7586edaad24ab6bfe2874c39ba9c3924bc9eb2a

Contents?: true

Size: 915 Bytes

Versions: 13

Compression:

Stored size: 915 Bytes

Contents

module BERTRPC
  module Encodes
    def encode_ruby_request(ruby_request)
      BERT.encode(ruby_request)
    end

    def decode_bert_response(bert_response)
      ruby_response = BERT.decode(bert_response)
      case ruby_response[0]
        when :reply
          ruby_response[1]
        when :noreply
          nil
        when :error
          error(ruby_response[1])
        else
          raise
      end
    end

    def error(err)
      level, code, klass, message, backtrace = err

      case level
        when :protocol
          raise ProtocolError.new([code, message], klass, backtrace)
        when :server
          raise ServerError.new([code, message], klass, backtrace)
        when :user
          raise UserError.new([code, message], klass, backtrace)
        when :proxy
          raise ProxyError.new([code, message], klass, backtrace)
        else
          raise
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
bertrpc-1.3.1 lib/bertrpc/encodes.rb
fd-bertrpc-1.3.1 lib/bertrpc/encodes.rb
fd-bertrpc-1.3.0 lib/bertrpc/encodes.rb
bertrpc-1.3.0 lib/bertrpc/encodes.rb
bertrpc-1.2.1 lib/bertrpc/encodes.rb
bertrpc-1.2.0 lib/bertrpc/encodes.rb
bertrpc-0.4.2 lib/bertrpc/encodes.rb
bertrpc-1.1.2 lib/bertrpc/encodes.rb
bertrpc-0.4.1 lib/bertrpc/encodes.rb
bertrpc-1.1.1 lib/bertrpc/encodes.rb
bertrpc-1.1.0 lib/bertrpc/encodes.rb
bertrpc-1.0.0 lib/bertrpc/encodes.rb
bertrpc-0.4.0 lib/bertrpc/encodes.rb