class FunWithJsonApi::SchemaValidators::CheckDocumentTypeMatchesResource
Attributes
schema_validator[R]
Public Class Methods
call(schema_validator)
click to toggle source
# File lib/fun_with_json_api/schema_validators/check_document_type_matches_resource.rb, line 4 def self.call(schema_validator) new(schema_validator).call end
new(schema_validator)
click to toggle source
# File lib/fun_with_json_api/schema_validators/check_document_type_matches_resource.rb, line 14 def initialize(schema_validator) @schema_validator = schema_validator end
Public Instance Methods
call()
click to toggle source
# File lib/fun_with_json_api/schema_validators/check_document_type_matches_resource.rb, line 18 def call if document_type != resource_type message = "'#{document_type}' does not match the expected resource"\ ": #{resource_type}" payload = ExceptionPayload.new( detail: document_type_does_not_match_endpoint_message ) raise Exceptions::InvalidDocumentType.new(message, payload) end end
Private Instance Methods
document_type_does_not_match_endpoint_message()
click to toggle source
# File lib/fun_with_json_api/schema_validators/check_document_type_matches_resource.rb, line 31 def document_type_does_not_match_endpoint_message I18n.t( :document_type_does_not_match_endpoint, expected: resource_type, scope: 'fun_with_json_api.schema_validators' ) end