Module: JSONAPI

Defined in:
lib/jsonapi.rb,
lib/jsonapi/link.rb,
lib/jsonapi/links.rb,
lib/jsonapi/parse.rb,
lib/jsonapi/error.rb,
lib/jsonapi/version.rb,
lib/jsonapi/jsonapi.rb,
lib/jsonapi/document.rb,
lib/jsonapi/resource.rb,
lib/jsonapi/attributes.rb,
lib/jsonapi/exceptions.rb,
lib/jsonapi/relationship.rb,
lib/jsonapi/relationships.rb,
lib/jsonapi/include_directive.rb,
lib/jsonapi/resource_identifier.rb,
lib/jsonapi/include_directive/parser.rb

Defined Under Namespace

Classes: Attributes, Document, Error, IncludeDirective, InvalidDocument, JsonApi, Link, Links, Relationship, Relationships, Resource, ResourceIdentifier

Constant Summary collapse

VERSION =
'0.1.1.beta2'.freeze

Class Method Summary collapse

Class Method Details

.parse(document, options = {}) ⇒ JSON::API::Document

Parse a JSON API document.

Parameters:

  • document (Hash, String)

    the JSON API document.

  • options (Hash) (defaults to: {})

    options

Options Hash (options):

  • :id_optional (Boolean) — default: false

    whether the resource objects in the primary data must have an id

Returns:

  • (JSON::API::Document)

13
14
15
16
17
# File 'lib/jsonapi/parse.rb', line 13

def parse(document, options = {})
  hash = document.is_a?(Hash) ? document : JSON.parse(document)

  Document.new(hash, options)
end