Class: Spree::EmailTemplates::SaveDraft

Inherits:
Workflow
  • Object
show all
Defined in:
app/workflows/spree/email_templates/save_draft.rb

Overview

Saves a draft of an editable email template, in any state: it is work in progress and customers keep receiving the published version. The first save starts from what is published, else Spree's default, and remembers that default so an upgrade changing it can be spotted.

A save carrying an older lock_version than the draft has is refused, so two admins editing at once cannot overwrite each other. rebase marks the draft as based on Spree's current default, for a merchant who reviewed an upgraded default and keeps their own version.

Instance Method Summary collapse

Methods inherited from Workflow

#call, define_argument_readers, #errors, #halt!, hooks, inherited, model_name, #read_attribute_for_validation, #reject!, workflow_key

Methods included from ServiceModule::Base

#call, prepended

Methods included from Workflow::ControlFlow

#failure

Instance Method Details

#perform(store:, key:, attributes:, locale: Spree::EmailTemplate::ANY_LOCALE, actor: nil) ⇒ Object



13
14
15
16
17
18
19
20
# File 'app/workflows/spree/email_templates/save_draft.rb', line 13

def perform(store:, key:, attributes:, locale: Spree::EmailTemplate::ANY_LOCALE, actor: nil)
  super
  step :ensure_editable
  step :ensure_current
  step :save

  success(draft)
end