A draft of an existing record — a page (MishkaDocument.SectionDraft) or a note
(MishkaDocument.NoteDraft) — names in its changed_fields which of the record's fields it
changes. Applying the draft writes those and no other
(MishkaDocument.Resources.Changes.AutoApplySectionDraft,
MishkaDocument.Resources.Changes.AutoApplyNoteDraft), so a field its editor did not change is
never written over, whatever the record holds by the time the draft is applied.
A draft added with a field left empty — nil, "", [], or an order of 0 — starts with the
record's value for it, so the draft shows what the record holds and changes none of it. Each
field it is given that differs from the record's is a change.
A draft edited later changes a field by setting it: to a value the record does not hold, it is a change; back to the record's own, it is none. A draft edited to name no permission opens its page to everyone once it is applied. A draft moved to another record is measured against that one.
A draft with no record — one that adds a page or a note — names none: applying it writes all of it, as the new record.
create :create do
change {MishkaDocument.Resources.Changes.StartFromSource,
source: :source_section_id,
resource: MishkaDocument.Section,
fields: [:title, :slug, :content, :permissions]}
endThe record is read as the action's caller — its actor, and the surface it came from — on the draft's site. A record it cannot read is never written over by a field the draft leaves empty: each field a draft added is given, and each one an edit sets, is taken as a change.
Options
:source- Required. The draft's attribute naming the record.:resource- Required. The record's resource.:fields- Required. The record's fields the draft holds, by the same name on both.