class ActiveRpc::Response

Attributes

error[RW]
id[R]
result[RW]

Public Class Methods

from_request(req) click to toggle source
# File lib/active_rpc/response.rb, line 23
def self.from_request(req)
  new(id: req.id)
end
new(id:) click to toggle source
# File lib/active_rpc/response.rb, line 6
def initialize(id:)
  @id = id
end

Public Instance Methods

to_hash() click to toggle source
# File lib/active_rpc/response.rb, line 10
def to_hash
  {
   'jsonrpc' => '2.0',
    'id' => id
  }.tap do |h|
    if error
      h['error'] = error.to_hash
    else
      h['result'] = result
    end
  end
end