Class: HttpStub::Server::Stub::Match::Match
- Inherits:
-
Object
- Object
- HttpStub::Server::Stub::Match::Match
- Defined in:
- lib/http_stub/server/stub/match/match.rb
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#stub ⇒ Object
readonly
Returns the value of attribute stub.
Instance Method Summary collapse
-
#initialize(request, response, stub) ⇒ Match
constructor
A new instance of Match.
- #matches?(criteria, _logger) ⇒ Boolean
- #to_json(*args) ⇒ Object
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
#request ⇒ Object (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 |
#response ⇒ Object (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 |
#stub ⇒ Object (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
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 |