Class: Aspera::JsonRpc::Client
- Inherits:
- BasicObject
- Defined in:
- lib/aspera/json_rpc/client.rb
Overview
JSON-RPC 2.0 client over an Aspera::Rest::Client HTTP endpoint. Methods are dispatched dynamically via method_missing. Based on BasicObject, so that methods of Object are sent as JSON-RPC requests. Example:
client = JsonRpc::Client.new(Rest::Client.new(base_url: 'http://127.0.0.1:33024'))
client.get_info
client.start_transfer(app_id: '...', transfer_spec: {...})
Instance Method Summary collapse
-
#initialize(api, namespace = nil) ⇒ Client
constructor
A new instance of Client.
-
#inspect ⇒ String
Class and URL of JSON-RPC endpoint.
-
#method_missing(method, *args) ⇒ Object
Dispatch any Ruby method call as a JSON-RPC request.
-
#respond_to_missing?(_sym, _include_private = false) ⇒ false
Ruby checks it before implicit conversions (
to_ary,to_str, ...): those are not JSON-RPC methods. -
#to_s ⇒ String
Same as #inspect.
Constructor Details
#initialize(api, namespace = nil) ⇒ Client
Returns a new instance of Client.
55 56 57 58 59 60 |
# File 'lib/aspera/json_rpc/client.rb', line 55 def initialize(api, namespace = nil) super() @api = api @namespace = namespace @request_id = 0 end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
Instance Method Details
#inspect ⇒ String
Returns Class and URL of JSON-RPC endpoint.
63 |
# File 'lib/aspera/json_rpc/client.rb', line 63 def inspect = "#<#{Client.name} #{@api.base_url}>" |
#respond_to_missing?(_sym, _include_private = false) ⇒ false
Ruby checks it before implicit conversions (to_ary, to_str, ...): those are not JSON-RPC methods
72 |
# File 'lib/aspera/json_rpc/client.rb', line 72 def respond_to_missing?(_sym, _include_private = false) = false |