Sha256: 7c65bac478ff45d07c04f88947705fa1db1d571635b5b8926fd29a88cbc1db5c

Contents?: true

Size: 830 Bytes

Versions: 1

Compression:

Stored size: 830 Bytes

Contents

module PipeRpc
  class Client < BasicInterface
    TRANSPORT_PREFIX = "__rpc_client__"

    def initialize(server_id = :default, hub)
      Kernel.raise ClientInitializationError.new("server id #{server_id.inspect} no symbol") unless server_id.is_a? Symbol
      @__rpc_server_id__ = server_id
      @__rpc_server_class_name__ = server_id.to_s.split('#').first
      @hub = hub
    end

    attr_reader :__rpc_server_class_name__, :__rpc_server_id__

    def respond_to?(method)
      super or method_missing(:respond_to?, method)
    end

    def method_missing(method, *args)
      request = Client::Request.new(@hub, server: @__rpc_server_id__, method: method, arguments: args)
      @hub.requests.evaluate(request)
    end

    def to_rpc_transport(hub = nil)
      "#{TRANSPORT_PREFIX}#{@__rpc_server_id__}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pipe_rpc-2.4.0 lib/pipe_rpc/client.rb