Class: HttpStub::Server::Stub::Match::Rule::JsonSchemaBody

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

Instance Method Summary collapse

Constructor Details

#initialize(schema_definition) ⇒ JsonSchemaBody

Returns a new instance of JsonSchemaBody.



9
10
11
# File 'lib/http_stub/server/stub/match/rule/json_schema_body.rb', line 9

def initialize(schema_definition)
  @schema_definition = schema_definition
end

Instance Method Details

#matches?(request, logger) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
# File 'lib/http_stub/server/stub/match/rule/json_schema_body.rb', line 13

def matches?(request, logger)
  validate_against_schema(request).tap do |errors|
    errors.each { |error| logger.info(error) }
  end.empty?
end

#to_sObject



19
20
21
# File 'lib/http_stub/server/stub/match/rule/json_schema_body.rb', line 19

def to_s
  @schema_definition.to_json
end