class JSONAPI::Parser::Relationship

Public Class Methods

parse!(document) click to toggle source

Validate the structure of a relationship update payload.

@param [Hash] document The input JSONAPI document. @raise [JSONAPI::Parser::InvalidDocument] if document is invalid.

# File lib/jsonapi/parser/relationship.rb, line 10
def self.parse!(document)
  Document.ensure!(document.is_a?(Hash),
                   'A JSON object MUST be at the root of every JSONAPI ' \
                   'request and response containing data.')
  Document.ensure!(document.keys == ['data'].freeze,
                   'A relationship update payload must contain primary ' \
                   'data.')
  Document.parse_relationship_data!(document['data'])
end