Class: Spree::PriceLists::Create

Inherits:
Workflow
  • Object
show all
Defined in:
app/workflows/spree/price_lists/create.rb

Overview

Creates a price list. A prices payload the list arrives with is applied by Spree::PriceLists::Update once the row exists, since both paths reconcile it the same way. Product membership is not part of this payload — it lives on the uniform nested products surface.

Instance Attribute Summary collapse

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 Attribute Details

#price_list ⇒ Object (readonly)

Returns the value of attribute price_list.



10
11
12
# File 'app/workflows/spree/price_lists/create.rb', line 10

def price_list
  @price_list
end

Instance Method Details

#perform(store:, attributes: {}) ⇒ Spree::ServiceModule::Result

Returns value is the price list.

Parameters:

  • store (Spree::Store)
  • attributes (Hash) (defaults to: {}) —

    may carry prices

Returns:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/workflows/spree/price_lists/create.rb', line 15

def perform(store:, attributes: {})
  super

  step :build_price_list
  run_hooks :validate

  ApplicationRecord.transaction do
    step :save_price_list
    step :apply_bulk_payloads
    run_hooks :after_create
  end

  success(price_list)
end