Class: Spree::Catalogs::SetPriceList

Inherits:
Workflow
  • Object
show all
Defined in:
app/workflows/spree/catalogs/set_price_list.rb

Overview

Writes the price list a catalog prices through, from an inline payload: creates the owned list, updates the one already owned, or removes it with nil (docs/plans/6.0-catalog-agreement-rework.md).

Removal happens only on an explicit price_list: null, never as a side effect of omitting the key.

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

#catalog ⇒ Object (readonly)

Returns the value of attribute catalog.



10
11
12
# File 'app/workflows/spree/catalogs/set_price_list.rb', line 10

def catalog
  @catalog
end

Instance Method Details

#perform(catalog:, attributes: nil) ⇒ Spree::ServiceModule::Result

Returns value is the catalog.

Parameters:

  • catalog (Spree::Catalog)
  • attributes (Hash, nil) (defaults to: nil) —

    list attributes, or nil to detach

Returns:



15
16
17
18
19
20
21
# File 'app/workflows/spree/catalogs/set_price_list.rb', line 15

def perform(catalog:, attributes: nil)
  super

  step :write_price_list

  success(catalog)
end