class RJR::Result
JSON-RPC Result
Representation
Attributes
Class
of error raised (if any) during request invocation (this is extra metadata beyond standard json-rpc)
Code corresponding to json-rpc error if problem occured during request invocation
Message corresponding to json-rpc error if problem occured during request invocation
Boolean indicating if request failed in some manner
Return value of the json-rpc call if successful
Boolean indicating if request was successfully invoked
Public Class Methods
JSON-RPC -32600 / Invalid Request
# File lib/rjr/result.rb, line 63 def self.invalid_request return Result.new(:error_code => -32600, :error_msg => 'Invalid Request') end
JSON-RPC -32602 / Method not found
# File lib/rjr/result.rb, line 69 def self.method_not_found(name) return Result.new(:error_code => -32602, :error_msg => "Method '#{name}' not found") end
RJR
result intializer @param [Hash] args options to set on result @option args [Object] :result result of json-rpc method handler if successfully returned @option args [Integer] :error_code code corresponding to json-rpc error if problem occured during request invocation @option args [String] :error_msg message corresponding to json-rpc error if problem occured during request invocation @option args [Class] :error_class class of error raised (if any) during request invocation (this is extra metadata beyond standard json-rpc)
# File lib/rjr/result.rb, line 34 def initialize(args = {}) @result = args[:result] || args['result'] @error_code = args[:error_code] || args['error_code'] @error_msg = args[:error_msg] || args['error_msg'] @error_class = args[:error_class] || args['error_class'] @success = @error_code.nil? @failed = !@error_code.nil? end
Public Instance Methods
Compare Result
against other result, returning true if both correspond to equivalent json-rpc results else false
# File lib/rjr/result.rb, line 46 def ==(other) @success == other.success && @failed == other.failed && @result == other.result && @error_code == other.error_code && @error_msg == other.error_msg && @error_class == other.error_class end
Convert Response to human consumable string
# File lib/rjr/result.rb, line 56 def to_s "#{@success} #{@result} #{@error_code} #{@error_msg} #{@error_class}" end