Class: ActiveRpc::Response
- Inherits:
-
Object
- Object
- ActiveRpc::Response
- Defined in:
- lib/active_rpc/response.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#result ⇒ Object
Returns the value of attribute result.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:) ⇒ Response
constructor
A new instance of Response.
- #to_hash ⇒ Object
Constructor Details
#initialize(id:) ⇒ Response
Returns a new instance of Response.
6 7 8 |
# File 'lib/active_rpc/response.rb', line 6 def initialize(id:) @id = id end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
3 4 5 |
# File 'lib/active_rpc/response.rb', line 3 def error @error end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/active_rpc/response.rb', line 4 def id @id end |
#result ⇒ Object
Returns the value of attribute result.
3 4 5 |
# File 'lib/active_rpc/response.rb', line 3 def result @result end |
Class Method Details
.from_request(req) ⇒ Object
23 24 25 |
# File 'lib/active_rpc/response.rb', line 23 def self.from_request(req) new(id: req.id) end |
Instance Method Details
#to_hash ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# 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 |