module SimpleJsonapi

Constants

MIME_TYPE
VERSION

Public Class Methods

render_errors(errors, options = {}) click to toggle source
# File lib/simple_jsonapi.rb, line 80
def self.render_errors(errors, options = {})
  document_options = normalize_render_options(
    options,
    errors: errors,
    serializer: error_serializer_inferrer,
  )

  Node::Document::Errors.new(document_options).as_jsonapi
end
render_resource(resource, options = {}) click to toggle source
# File lib/simple_jsonapi.rb, line 60
def self.render_resource(resource, options = {})
  document_options = normalize_render_options(
    options,
    resource: resource,
    serializer: serializer_inferrer,
  )

  Node::Document::Singular.new(document_options).as_jsonapi
end
render_resources(resources, options = {}) click to toggle source
# File lib/simple_jsonapi.rb, line 70
def self.render_resources(resources, options = {})
  document_options = normalize_render_options(
    options,
    resources: resources,
    serializer: serializer_inferrer,
  )

  Node::Document::Collection.new(document_options).as_jsonapi
end

Private Class Methods

normalize_render_options(options, defaults) click to toggle source
# File lib/simple_jsonapi.rb, line 90
def self.normalize_render_options(options, defaults)
  defaults.merge(options.symbolize_keys).transform_keys do |key|
    key == :serializer ? :serializer_inferrer : key
  end
end