MishkaBlog.Resources.Preparations.PreviewVersion (Mishka Blog v0.0.1)

Copy Markdown View Source

Turns a read of one record into a preview of it as it was in one of its own versions, named by the read's :version_id argument. Nothing is saved.

The version is read as the caller, with no tenant when :master is set. A version of any other record is refused with MishkaBlog.Resources.Changes.RestoreVersion.refusal/1, and one that cannot be read comes back as the read's own error. Nothing raises.

Usage

read :preview_version do
  get? true

  argument :tag_id, :uuid, allow_nil?: false
  argument :version_id, :uuid, allow_nil?: false

  filter expr(id == ^arg(:tag_id))

  prepare {MishkaBlog.Resources.Preparations.PreviewVersion,
           version: MishkaBlog.Tag.Version,
           label: "tag"}
end

Options

  • :version - Required. The record's version resource. It needs a :get_any read.
  • :label - Required. How the refusal names the record, such as "tag".
  • :fields - The attributes taken from the version. Defaults to every field of the record.
  • :cast - Fields whose string value is read through the attribute's own type.
  • :master - Read the version with no tenant. Defaults to false.

Summary

Functions

supports(opts)

Callback implementation for Ash.Resource.Preparation.supports/1.

temporal_safe?(opts)

Callback implementation for Ash.Resource.Preparation.temporal_safe?/1.