Class: RJR::Result
Overview
JSON-RPC Result Representation
Instance Attribute Summary collapse
-
#error_class ⇒ Object
Class of error raised (if any) during request invocation (this is extra metadata beyond standard json-rpc).
-
#error_code ⇒ Object
Code corresponding to json-rpc error if problem occured during request invocation.
-
#error_msg ⇒ Object
Message corresponding to json-rpc error if problem occured during request invocation.
-
#failed ⇒ Object
Boolean indicating if request failed in some manner.
-
#result ⇒ Object
Return value of the json-rpc call if successful.
-
#success ⇒ Object
Boolean indicating if request was successfully invoked.
Class Method Summary collapse
-
.invalid_request ⇒ Object
JSON-RPC -32600 / Invalid Request.
-
.method_not_found(name) ⇒ Object
JSON-RPC -32602 / Method not found.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Compare Result against other result, returning true if both correspond to equivalent json-rpc results else false.
-
#initialize(args = {}) ⇒ Result
constructor
RJR result intializer.
-
#to_s ⇒ Object
Convert Response to human consumable string.
Constructor Details
#initialize(args = {}) ⇒ Result
RJR result intializer
34 35 36 37 38 39 40 41 42 |
# 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 |
Instance Attribute Details
#error_class ⇒ Object
Class of error raised (if any) during request invocation (this is extra metadata beyond standard json-rpc)
26 27 28 |
# File 'lib/rjr/result.rb', line 26 def error_class @error_class end |
#error_code ⇒ Object
Code corresponding to json-rpc error if problem occured during request invocation
20 21 22 |
# File 'lib/rjr/result.rb', line 20 def error_code @error_code end |
#error_msg ⇒ Object
Message corresponding to json-rpc error if problem occured during request invocation
23 24 25 |
# File 'lib/rjr/result.rb', line 23 def error_msg @error_msg end |
#failed ⇒ Object
Boolean indicating if request failed in some manner
14 15 16 |
# File 'lib/rjr/result.rb', line 14 def failed @failed end |
#result ⇒ Object
Return value of the json-rpc call if successful
17 18 19 |
# File 'lib/rjr/result.rb', line 17 def result @result end |
#success ⇒ Object
Boolean indicating if request was successfully invoked
11 12 13 |
# File 'lib/rjr/result.rb', line 11 def success @success end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object
Compare Result against other result, returning true if both correspond to equivalent json-rpc results else false
46 47 48 49 50 51 52 53 |
# 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 |
#to_s ⇒ Object
Convert Response to human consumable string
56 57 58 |
# File 'lib/rjr/result.rb', line 56 def to_s "#{@success} #{@result} #{@error_code} #{@error_msg} #{@error_class}" end |