Class: Spree::Variants::Update
- Includes:
- NestedAttributes
- Defined in:
- app/workflows/spree/variants/update.rb
Overview
Updates a variant, reconciling the option values, prices and stock levels the payload carries (see Spree::Variants::NestedAttributes — prices replace, stock levels and options upsert).
Handlers reading variant.changes in :validate see the pending edit
before it is written.
Instance Method Summary collapse
-
#perform(variant:, attributes: {}) ⇒ Spree::ServiceModule::Result
Value is the variant.
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(variant:, attributes: {}) ⇒ Spree::ServiceModule::Result
Returns value is the variant.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/workflows/spree/variants/update.rb', line 17 def perform(variant:, attributes: {}) super step :assign_attributes run_hooks :validate ApplicationRecord.transaction do step :save_variant step :apply_nested_attributes run_hooks :after_update end success(variant) end |