calcinator v1.6.0 Calcinator.View behaviour

A view for Calcinator.Resources

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)

Types

maybe_pagination()
maybe_pagination() :: nil | pagination

pagination or nil if no pagination

pagination()
pagination() :: map
params()
params() :: %{optional(String.t) => term}

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

related()
related() :: nil | struct | [struct]

Resource(s) related to resource through a relationship

subject()
subject() :: term

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

Callbacks

index(list, %{})
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.

show(struct, %{})
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).

show_relationship(related, %{})
show_relationship(related, %{optional(:params) => params, optional(:related) => related, optional(:source) => struct, optional(:subject) => subject}) :: iodata

Renders the relationship iodata for the given related.