Class: HttpStub::Server::Stub::Match::Rules
- Inherits:
-
Object
- Object
- HttpStub::Server::Stub::Match::Rules
- Defined in:
- lib/http_stub/server/stub/match/rules.rb
Constant Summary collapse
- EMPTY =
self.new(uri: "", method: "", headers: {}, parameters: {}, body: "").freeze
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(args) ⇒ Rules
constructor
A new instance of Rules.
- #matches?(request, logger) ⇒ Boolean
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(args) ⇒ Rules
Returns a new instance of Rules.
10 11 12 13 14 15 16 |
# File 'lib/http_stub/server/stub/match/rules.rb', line 10 def initialize(args) @uri = HttpStub::Server::Stub::Match::Rule::Uri.new(args[:uri]) @method = HttpStub::Server::Stub::Match::Rule::Method.new(args[:method]) @headers = HttpStub::Server::Stub::Match::Rule::Headers.new(args[:headers]) @parameters = HttpStub::Server::Stub::Match::Rule::Parameters.new(args[:parameters]) @body = HttpStub::Server::Stub::Match::Rule::Body.create(args[:body]) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
8 9 10 |
# File 'lib/http_stub/server/stub/match/rules.rb', line 8 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
8 9 10 |
# File 'lib/http_stub/server/stub/match/rules.rb', line 8 def headers @headers end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
8 9 10 |
# File 'lib/http_stub/server/stub/match/rules.rb', line 8 def method @method end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
8 9 10 |
# File 'lib/http_stub/server/stub/match/rules.rb', line 8 def parameters @parameters end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
8 9 10 |
# File 'lib/http_stub/server/stub/match/rules.rb', line 8 def uri @uri end |
Instance Method Details
#matches?(request, logger) ⇒ Boolean
20 21 22 |
# File 'lib/http_stub/server/stub/match/rules.rb', line 20 def matches?(request, logger) [ @uri, @method, @headers, @parameters, @body ].all? { |matcher| matcher.matches?(request, logger) } end |
#to_json(*args) ⇒ Object
24 25 26 |
# File 'lib/http_stub/server/stub/match/rules.rb', line 24 def to_json(*args) { uri: @uri, method: @method, headers: @headers, parameters: @parameters, body: @body }.to_json(*args) end |