Class: GrpcMock::RequestPattern
- Inherits:
-
Object
- Object
- GrpcMock::RequestPattern
- Defined in:
- lib/grpc_mock/request_pattern.rb
Instance Method Summary collapse
-
#initialize(path) ⇒ RequestPattern
constructor
A new instance of RequestPattern.
- #match?(path, request) ⇒ Boolean
- #with(request = nil, &block) ⇒ Object
Constructor Details
#initialize(path) ⇒ RequestPattern
Returns a new instance of RequestPattern.
6 7 8 9 10 |
# File 'lib/grpc_mock/request_pattern.rb', line 6 def initialize(path) @path = path @block = nil @request = nil end |
Instance Method Details
#match?(path, request) ⇒ Boolean
21 22 23 |
# File 'lib/grpc_mock/request_pattern.rb', line 21 def match?(path, request) @path == path && (@request.nil? || @request == request) && (@block.nil? || @block.call(path)) end |
#with(request = nil, &block) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/grpc_mock/request_pattern.rb', line 12 def with(request = nil, &block) if request.nil? && !block_given? raise ArgumentError, '#with method invoked with no arguments. Either options request or block must be specified.' end @request = request @block = block end |