class Lurker::Json::ResponseCodes
Constants
- STATUS
- SUCCESSFUL
Public Class Methods
new(schema, options = {})
click to toggle source
Calls superclass method
Lurker::Json::Schema::new
# File lib/lurker/json/schema/response_codes.rb, line 7 def initialize(schema, options = {}) @parent_property = 'responseCodes' super end
Public Instance Methods
exists?(status_code, successful)
click to toggle source
# File lib/lurker/json/schema/response_codes.rb, line 29 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
merge!(status_code, successful)
click to toggle source
# File lib/lurker/json/schema/response_codes.rb, line 13 def merge!(status_code, successful) return if exists?(status_code, successful) payload = {STATUS => status_code, SUCCESSFUL => successful, Json::DESCRIPTION => ''} @schema << Lurker::Json::Parser.plain(root_schema: root_schema).parse(payload) end
validate!(status_code, successful)
click to toggle source
# File lib/lurker/json/schema/response_codes.rb, line 20 def validate!(status_code, successful) return if exists?(status_code, successful) raise Lurker::UndocumentedResponseCode, 'Undocumented response: %s, successful: %s' % [ status_code, successful ] end