Class: Spree::DigitalAssets::Update
- Includes:
- Writing
- Defined in:
- app/workflows/spree/digital_assets/update.rb
Overview
Changes a digital asset: its download limits, the variant it hangs off, or the file itself. Replacing the file keeps every already-issued link working, since links resolve through the asset rather than the blob.
Handlers reading digital_asset.changes in :validate see the pending
edit; blob is the replacement file, when the payload carries one.
Constant Summary
Constants included from Writing
Instance Method Summary collapse
-
#perform(digital_asset:, attributes: {}, seller: nil, submitted_by: nil) ⇒ Spree::ServiceModule::Result
Value is the digital asset.
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
Methods included from Workflow::ControlFlow
Instance Method Details
#perform(digital_asset:, attributes: {}, seller: nil, submitted_by: nil) ⇒ Spree::ServiceModule::Result
Returns value is the digital asset.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/workflows/spree/digital_assets/update.rb', line 19 def perform(digital_asset:, attributes: {}, seller: nil, submitted_by: nil) super step :assign_attributes step :resolve_upload step :enforce_seller_rules run_hooks :validate ApplicationRecord.transaction do step :attach_upload step :save_digital_asset step :reopen_review run_hooks :after_update end success(digital_asset) end |