Class: Spree::PriceLists::Activate

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

Overview

Puts a price list into effect. A list whose start date is still in the future is scheduled instead of activated, so activating is always the single answer to "make this list live" regardless of its dates.

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(price_list:) ⇒ Spree::ServiceModule::Result

Returns value is the price list.

Parameters:

Returns:



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/workflows/spree/price_lists/activate.rb', line 11

def perform(price_list:)
  super

  step :require_something_to_apply_to
  run_hooks :validate

  ApplicationRecord.transaction do
    step :mark_live
    run_hooks :after_activate
  end

  success(price_list)
end