Class: Lnrpc::GrpcWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/lnrpc/grpc_wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service:, grpc:) ⇒ GrpcWrapper



5
6
7
8
# File 'lib/lnrpc/grpc_wrapper.rb', line 5

def initialize(service:, grpc:)
  @grpc = grpc
  @service = service
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



10
11
12
13
14
15
16
17
18
19
# File 'lib/lnrpc/grpc_wrapper.rb', line 10

def method_missing(m, *args, &block)
  if grpc.respond_to?(m)
    params = args[0]

    args[0] = params.nil? ? request_class_for(m).new : request_class_for(m).new(params)
    grpc.send(m, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#grpcObject (readonly)

Returns the value of attribute grpc.



3
4
5
# File 'lib/lnrpc/grpc_wrapper.rb', line 3

def grpc
  @grpc
end

#serviceObject (readonly)

Returns the value of attribute service.



3
4
5
# File 'lib/lnrpc/grpc_wrapper.rb', line 3

def service
  @service
end

Instance Method Details

#inspectObject



21
22
23
# File 'lib/lnrpc/grpc_wrapper.rb', line 21

def inspect
  "#{self} @grpc=\"#{grpc}\""
end