calcinator v4.1.0-rc1 Calcinator.View behaviour View Source

A view for Calcinator.Resources

Link to this section Summary

Types

pagination or nil if no pagination

The raw request params that need to be parsed for view options

Resource(s) related to resource through a relationship

The subject that must be authorized to view the individual attributes in the view

Callbacks

Rendered related iodata

Renders list of struct with optional pagination, params, and subject (for view-level authorization of individual attributes). base_uri is required when pagination is present

Renders the show iodata for the given struct and optional params and subject (for view-level authorization of individual attributes)

Link to this section Types

Link to this type maybe_pagination() View Source
maybe_pagination() :: nil | pagination()

pagination or nil if no pagination

Link to this type pagination() View Source
pagination() :: map()
Link to this type params() View Source
params() :: %{optional(String.t()) => term()}

The raw request params that need to be parsed for view options

Link to this type related() View Source
related() :: nil | struct() | [struct()]

Resource(s) related to resource through a relationship

Link to this type subject() View Source
subject() :: term()

The subject that must be authorized to view the individual attributes in the view.

Link to this section Callbacks

Link to this callback index(list, %{}) View Source
index([struct()], %{
  optional(:base_uri) => URI.t(),
  optional(:pagination) => maybe_pagination(),
  optional(:params) => params(),
  optional(:subject) => subject()
}) :: iodata()

Renders list of struct with optional pagination, params, and subject (for view-level authorization of individual attributes). base_uri is required when pagination is present.

Link to this callback show(struct, %{}) View Source
show(struct(), %{optional(:params) => params(), optional(:subject) => subject()}) ::
  iodata()

Renders the show iodata for the given struct and optional params and subject (for view-level authorization of individual attributes).

Link to this callback show_relationship(related, %{}) View Source
show_relationship(related(), %{
  optional(:params) => params(),
  optional(:related) => related(),
  optional(:source) => struct(),
  optional(:subject) => subject()
}) :: iodata()

Renders the relationship iodata for the given related.