class FunWithJsonApi::SchemaValidator
Attributes
deserializer[R]
document[R]
resource[R]
Public Class Methods
check(document, deserializer, resource)
click to toggle source
# File lib/fun_with_json_api/schema_validator.rb, line 5 def self.check(document, deserializer, resource) new(document, deserializer, resource).check end
new(document, deserializer, resource)
click to toggle source
# File lib/fun_with_json_api/schema_validator.rb, line 15 def initialize(document, deserializer, resource) @document = FunWithJsonApi.sanitize_document(document) @deserializer = deserializer @resource = resource end
Public Instance Methods
check()
click to toggle source
# File lib/fun_with_json_api/schema_validator.rb, line 21 def check FunWithJsonApi::SchemaValidators::CheckDocumentTypeMatchesResource.call(self) FunWithJsonApi::SchemaValidators::CheckDocumentIdMatchesResource.call(self) FunWithJsonApi::SchemaValidators::CheckAttributeNames.call(document, deserializer) FunWithJsonApi::SchemaValidators::CheckRelationships.call(document, deserializer) end
document_id()
click to toggle source
# File lib/fun_with_json_api/schema_validator.rb, line 28 def document_id @document_id ||= document['data']['id'] end
document_type()
click to toggle source
# File lib/fun_with_json_api/schema_validator.rb, line 32 def document_type @document_type ||= document['data']['type'] end
resource_id()
click to toggle source
# File lib/fun_with_json_api/schema_validator.rb, line 36 def resource_id @resource_id ||= resource.send(deserializer.id_param).to_s end
resource_type()
click to toggle source
# File lib/fun_with_json_api/schema_validator.rb, line 40 def resource_type @resource_type ||= deserializer.type end