module
JSONAPI::Resource
Overview
Mixin providing a declarative DSL (#jsonapi_type, jsonapi_attributes,
jsonapi_has_one, jsonapi_has_many) for JSON:API v1.1 resource serialization.
Defined in:
jsonapi/include_tree.crjsonapi/resource.cr
Macro Summary
-
jsonapi_attribute(name, key = nil, &block)
Exposes a single attribute with an optional serialized
keyor value block. -
jsonapi_attributes(*names)
Exposes one or more methods/properties as JSON:API
attributes. -
jsonapi_has_many(name, key = nil, &block)
Declares a to-many relationship (
has_many). -
jsonapi_has_one(name, key = nil, &block)
Declares a to-one relationship (
has_one). -
jsonapi_id(method_name = nil, &block)
Customizes the JSON:API
idaccessor (defaults to#id.to_s). -
jsonapi_type(name)
Declares the JSON:API
typestring for this resource class.
Instance Method Summary
Macro Detail
macro jsonapi_attribute(name, key = nil, &block)
#
Exposes a single attribute with an optional serialized key or value block.
macro jsonapi_id(method_name = nil, &block)
#
Customizes the JSON:API id accessor (defaults to #id.to_s).