Class: JSONRPC::BatchClient

Inherits:
Base
  • Object
show all
Defined in:
lib/jsonrpc/client.rb

Constant Summary

Constants inherited from Base

JSONRPC::Base::JSON_RPC_VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#class, #inspect, make_id, #to_s

Constructor Details

#initialize(url, opts = {}) {|_self| ... } ⇒ BatchClient

Returns a new instance of BatchClient.

Yields:

  • (_self)

Yield Parameters:



84
85
86
87
88
89
90
91
# File 'lib/jsonrpc/client.rb', line 84

def initialize(url, opts = {})
  super
  @batch = []
  @alive = true
  yield self
  send_batch
  @alive = false
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



93
94
95
96
97
98
99
100
# File 'lib/jsonrpc/client.rb', line 93

def method_missing(sym, *args, &block)
  if @alive
    request = ::JSONRPC::Request.new(sym.to_s, args)
    push_batch_request(request)
  else
    super
  end
end

Instance Attribute Details

#batchObject (readonly)

Returns the value of attribute batch.



82
83
84
# File 'lib/jsonrpc/client.rb', line 82

def batch
  @batch
end