Sha256: c679cfbe23766eaa7ebdbfe9b9d640c06ef636a33e3be504744f0a714f41bc98

Contents?: true

Size: 834 Bytes

Versions: 1

Compression:

Stored size: 834 Bytes

Contents

# frozen_string_literal: true

module GrpcMock
  class OperationStub
    attr_reader :response_proc, :metadata, :trailing_metadata, :deadline

    # @param metadata [Hash] Any metadata passed into the GRPC request
    # @param deadline [Time] The deadline set on the GRPC request
    # @yieldreturn [*] The stubbed value or error expected to be returned from the request
    def initialize(metadata: nil, deadline: nil, &response_proc)
      @response_proc = response_proc
      @metadata = metadata
      @deadline = deadline

      # TODO: support stubbing
      @trailing_metadata = {}
    end

    # Calls the block given upon instantiation and returns the result
    def response
      response_proc.call
    end
    alias_method :execute, :response

    # TODO: support stubbing
    def cancelled?
      false
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gruffish-0.5.0.pre1 lib/grpc_mock/operation_stub.rb