Sha256: ba75dc9105d46fca75df97c45a2c60204cea7860464775209215dae0096437a1

Contents?: true

Size: 517 Bytes

Versions: 4

Compression:

Stored size: 517 Bytes

Contents

module JPC
  module Helpers
    def make_message(data)
      message = { jsonrpc: JPC::RPC_VERSION }.merge!(data)
      Oj.dump(message, mode: :compat)
    end

    def make_response(id, data)
      response = { id: id }.merge!(data)
      make_message(response)
    end

    def make_result(id, result)
      make_response(id, result: result)
    end

    def make_error(id, code, message)
      error = {
        code: code,
        message: message
      }

      make_response(id, error: error)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jpc-1.3.0 lib/jpc/helpers.rb
jpc-1.2.1 lib/jpc/helpers.rb
jpc-1.2.0 lib/jpc/helpers.rb
jpc-1.1.0 lib/jpc/helpers.rb