MishkaCmsCore. Runtime. Resources. Changes. RestoreVersion
(Mishka CMS Core v0.0.1)
Copy Markdown
View Source
Copies a version's snapshot back onto the record it was taken of.
The :version_id argument must name one of THIS record's versions. A version of any other record
— another site's included — is refused on :version_id with the same words a missing one gets, so
the answer does not say which ids exist elsewhere. Nothing of the refused version reaches the
changeset.
Only the fields the resource's primary :update accepts are copied, and never site_id: a restore
changes what a record says, not which site it belongs to. Values are cast by each attribute's own
type, so an atom field stored as a string in the snapshot comes back as the atom.
Options
:version— the resource's AshPaperTrail version resource. Required. It must have a:get_anyread.
Usage
update :restore_version do
argument :version_id, :uuid, allow_nil?: false
change {MishkaCmsCore.Runtime.Resources.Changes.RestoreVersion,
version: MishkaCmsCore.Runtime.Layout.Version}
end
Summary
Functions
A version's snapshot as a map: %{} when it holds none or cannot be read.
record as a version's snapshot says it was, for showing and never for saving.
Functions
A version's snapshot as a map: %{} when it holds none or cannot be read.
record as a version's snapshot says it was, for showing and never for saving.
Pass the record, its resource, the version's changes (a map, its JSON, or nil) and, to name
the fields yourself, the attributes that may be shown (the resource's primary :update accepts
by default). A key that is not one of them is left out, and a value stored as text for an
attribute of type :atom comes back as the atom, cast by the attribute's own type.