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.cr
jsonapi/resource.cr

Macro Summary

Instance Method Summary

Macro Detail

macro jsonapi_attribute(name, key = nil, &block) #

Exposes a single attribute with an optional serialized key or value block.


[View source]
macro jsonapi_attributes(*names) #

Exposes one or more methods/properties as JSON:API attributes.


[View source]
macro jsonapi_has_many(name, key = nil, &block) #

Declares a to-many relationship (has_many).


[View source]
macro jsonapi_has_one(name, key = nil, &block) #

Declares a to-one relationship (has_one).


[View source]
macro jsonapi_id(method_name = nil, &block) #

Customizes the JSON:API id accessor (defaults to #id.to_s).


[View source]
macro jsonapi_type(name) #

Declares the JSON:API type string for this resource class.


[View source]

Instance Method Detail

abstract def jsonapi_id : String #

[View source]
abstract def jsonapi_type : String #

[View source]