Module: SimpleJsonapi
- Defined in:
- lib/simple_jsonapi.rb,
lib/simple_jsonapi/version.rb,
lib/simple_jsonapi/helpers/exceptions.rb,
lib/simple_jsonapi/helpers/serializer_inferrer.rb,
lib/simple_jsonapi/definition/concerns/has_meta_object.rb,
lib/simple_jsonapi/definition/concerns/has_links_object.rb
Defined Under Namespace
Modules: Definition, Errors, Node, Parameters, SerializerMethods
Classes: DuplicateResourceError, ErrorSerializer, InvalidJsonStructureError, Serializer, SerializerInferenceError, SerializerInferrer
Constant Summary
collapse
- MIME_TYPE =
'application/vnd.api+json'.freeze
- VERSION =
'1.1.0'.freeze
Class Method Summary
collapse
Class Method Details
.render_errors(errors, options = {}) ⇒ Object
80
81
82
83
84
85
86
87
88
|
# 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 = {}) ⇒ Object
60
61
62
63
64
65
66
67
68
|
# 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 = {}) ⇒ Object
70
71
72
73
74
75
76
77
78
|
# 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
|