Class: JSONAPI::Parser::Relationship

Inherits:
Object
  • Object
show all
Defined in:
lib/jsonapi/parser/relationship.rb

Class Method Summary collapse

Class Method Details

.parse!(document) ⇒ Object

Validate the structure of a relationship update payload.

Parameters:

  • document (Hash)

    The input JSONAPI document.

Raises:



10
11
12
13
14
15
16
17
18
# 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