Sha256: ec3cb5c47a1d8a2ffd46f65e322036d7237785feb5c84e0caa24ca6c0a7e5fa7
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
module Lurker module Json class ResponseCodes < Schema STATUS = 'status'.freeze SUCCESSFUL = 'successful'.freeze DESCRIPTION = 'description'.freeze def initialize(schema, options = {}) @parent_property = 'responseCodes' super end def merge!(status_code, successful) return if exists?(status_code, successful) payload = {STATUS => status_code, SUCCESSFUL => successful, DESCRIPTION => ''} @schema << Lurker::Json::Parser.plain(root_schema: root_schema).parse(payload) end def validate!(status_code, successful) return if exists?(status_code, successful) raise Lurker::UndocumentedResponseCode, 'Undocumented response: %s, successful: %s' % [ status_code, successful ] end def exists?(status_code, successful) !!@schema.detect do |response_code| response_code[SUCCESSFUL] == successful && (response_code[STATUS] == status_code || # 200 response_code[STATUS].to_i == status_code) # "200 OK" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lurker-0.6.3 | lib/lurker/json/schema/response_codes.rb |