Class: JSONAPI::Parser::Resource
- Inherits:
-
Object
- Object
- JSONAPI::Parser::Resource
- Defined in:
- lib/jsonapi/parser/resource.rb
Class Method Summary collapse
-
.parse!(document) ⇒ Object
Validate the structure of a resource create/update payload.
Class Method Details
.parse!(document) ⇒ Object
Validate the structure of a resource create/update payload.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/jsonapi/parser/resource.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 && document['data'].is_a?(Hash), 'The request MUST include a single resource object ' \ 'as primary data.') Document.parse_primary_resource!(document['data']) end |