Class: Spree::OrderRouting::Strategy::Base
- Inherits:
-
Object
- Object
- Spree::OrderRouting::Strategy::Base
- Defined in:
- app/models/spree/order_routing/strategy/base.rb
Overview
Contract for order routing strategies. Subclasses implement all four methods — there are no defaults. New routing signals (proximity, day-of-week, etc.) ship as STI subclasses of Spree::OrderRoutingRule; a custom strategy is appropriate only when the algorithm itself is a different shape (OMS delegation, ML model, optimization solver).
Selected per Order via Spree::Order#order_routing_strategy. See docs/plans/6.0-order-routing.md.
Instance Attribute Summary collapse
-
#order ⇒ Object
readonly
Returns the value of attribute order.
Class Method Summary collapse
-
.display_name ⇒ String
Human label for admin strategy pickers.
Instance Method Summary collapse
- #for_allocation ⇒ Array<Spree::Stock::Package>
- #for_cancellation ⇒ Object
- #for_release ⇒ Object
- #for_sale(fulfillment:) ⇒ Object
-
#initialize(order:) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(order:) ⇒ Base
Returns a new instance of Base.
23 24 25 |
# File 'app/models/spree/order_routing/strategy/base.rb', line 23 def initialize(order:) @order = order end |
Instance Attribute Details
#order ⇒ Object (readonly)
Returns the value of attribute order.
13 14 15 |
# File 'app/models/spree/order_routing/strategy/base.rb', line 13 def order @order end |
Class Method Details
.display_name ⇒ String
Human label for admin strategy pickers. Override in a subclass or add an i18n key under spree.order_routing.strategies.
19 20 21 |
# File 'app/models/spree/order_routing/strategy/base.rb', line 19 def self.display_name Spree.t(name.demodulize.underscore, scope: 'order_routing.strategies', default: name.demodulize.titleize) end |
Instance Method Details
#for_allocation ⇒ Array<Spree::Stock::Package>
28 29 30 |
# File 'app/models/spree/order_routing/strategy/base.rb', line 28 def for_allocation raise NotImplementedError, "#{self.class} must implement #for_allocation" end |
#for_cancellation ⇒ Object
41 42 43 |
# File 'app/models/spree/order_routing/strategy/base.rb', line 41 def for_cancellation raise NotImplementedError, "#{self.class} must implement #for_cancellation" end |
#for_release ⇒ Object
37 38 39 |
# File 'app/models/spree/order_routing/strategy/base.rb', line 37 def for_release raise NotImplementedError, "#{self.class} must implement #for_release" end |
#for_sale(fulfillment:) ⇒ Object
33 34 35 |
# File 'app/models/spree/order_routing/strategy/base.rb', line 33 def for_sale(fulfillment:) raise NotImplementedError, "#{self.class} must implement #for_sale" end |