Class: ProtoPharm::OperationStub

Inherits:
Object
  • Object
show all
Defined in:
lib/proto_pharm/operation_stub.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metadata: nil, deadline: nil, &response_proc) ⇒ OperationStub

Returns a new instance of OperationStub.

Parameters:

  • metadata (Hash) (defaults to: nil)

    Any metadata passed into the GRPC request

  • deadline (Time) (defaults to: nil)

    The deadline set on the GRPC request

Yield Returns:

  • (*)

    The stubbed value or error expected to be returned from the request



10
11
12
13
14
15
16
17
# File 'lib/proto_pharm/operation_stub.rb', line 10

def initialize(metadata: nil, deadline: nil, &response_proc)
  @response_proc = response_proc
  @metadata = 
  @deadline = deadline

  # TODO: support stubbing
  @trailing_metadata = {}
end

Instance Attribute Details

#deadlineObject (readonly)

Returns the value of attribute deadline.



5
6
7
# File 'lib/proto_pharm/operation_stub.rb', line 5

def deadline
  @deadline
end

#metadataObject (readonly)

Returns the value of attribute metadata.



5
6
7
# File 'lib/proto_pharm/operation_stub.rb', line 5

def 
  @metadata
end

#response_procObject (readonly)

Returns the value of attribute response_proc.



5
6
7
# File 'lib/proto_pharm/operation_stub.rb', line 5

def response_proc
  @response_proc
end

#trailing_metadataObject (readonly)

Returns the value of attribute trailing_metadata.



5
6
7
# File 'lib/proto_pharm/operation_stub.rb', line 5

def 
  @trailing_metadata
end

Instance Method Details

#cancelled?Boolean

TODO: support stubbing

Returns:

  • (Boolean)


26
27
28
# File 'lib/proto_pharm/operation_stub.rb', line 26

def cancelled?
  false
end

#responseObject Also known as: execute

Calls the block given upon instantiation and returns the result



20
21
22
# File 'lib/proto_pharm/operation_stub.rb', line 20

def response
  response_proc.call
end