module Roar::JSON::JSONAPI::Document
Instance method API for JSON
API Documents.
Public Instance Methods
to_hash(options = {})
click to toggle source
Render the document as a Ruby Hash
@option options [Array<#to_s>,#to_s,false] include
compound documents to include, specified as a list of relationship paths (Array or comma-separated String) or `false`, if no compound documents are to be included. N.B. this syntax and behaviour for this option *is signficantly different* to that of the `include` option implemented in other, non-JSON API Representers.
@option options [Hash{ Calls superclass method
# File lib/roar/json/json_api/document.rb, line 53 def to_hash(options = {}) super end
to_json(options = {})
click to toggle source
Render the document as JSON
@example Simple rendering
representer.to_json
@example Rendering with compound documents and sparse fieldsets
uri = Addressable::URI.parse('/articles/1?include=author,comments.author') query = Rack::Utils.parse_nested_query(uri.query) # => {"include"=>"author", "fields"=>{"articles"=>"title,body", "people"=>"name"}} representer.to_json( include: query['include'], fields: query['fields'] )
@option options (see to_hash
)
@return [String] JSON
String
@see jsonapi.org/format/#fetching-includes @see jsonapi.org/format/#fetching-sparse-fieldsets @api public
Calls superclass method
# File lib/roar/json/json_api/document.rb, line 29 def to_json(options = {}) super end