Class: HttpStub::Server::Stub::Match::Match

Inherits:
Object
  • Object
show all
Defined in:
lib/http_stub/server/stub/match/match.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request, response, stub) ⇒ Match

Returns a new instance of Match.


10
11
12
13
14
# File 'lib/http_stub/server/stub/match/match.rb', line 10

def initialize(request, response, stub)
  @request  = request
  @response = response
  @stub     = stub
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request


8
9
10
# File 'lib/http_stub/server/stub/match/match.rb', line 8

def request
  @request
end

#responseObject (readonly)

Returns the value of attribute response


8
9
10
# File 'lib/http_stub/server/stub/match/match.rb', line 8

def response
  @response
end

#stubObject (readonly)

Returns the value of attribute stub


8
9
10
# File 'lib/http_stub/server/stub/match/match.rb', line 8

def stub
  @stub
end

Instance Method Details

#matches?(criteria, _logger) ⇒ Boolean

Returns:

  • (Boolean)

16
17
18
# File 'lib/http_stub/server/stub/match/match.rb', line 16

def matches?(criteria, _logger)
  @request.uri.include?(criteria[:uri]) && @request.method.casecmp(criteria[:method]).zero?
end

#to_json(*args) ⇒ Object


20
21
22
# File 'lib/http_stub/server/stub/match/match.rb', line 20

def to_json(*args)
  { request: @request, response: @response, stub: @stub }.to_json(*args)
end