Class: Spree::OrderRouting::Strategy::Base
- Inherits:
-
Object
- Object
- Spree::OrderRouting::Strategy::Base
- Extended by:
- ApiTyped
- 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.
Direct Known Subclasses
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.
Methods included from ApiTyped
api_type, api_type_for, api_typed_family, class_name_for, find, registered_class
Constructor Details
#initialize(order:) ⇒ Base
Returns a new instance of Base.
25 26 27 |
# File 'app/models/spree/order_routing/strategy/base.rb', line 25 def initialize(order:) @order = order end |
Instance Attribute Details
#order ⇒ Object (readonly)
Returns the value of attribute order.
15 16 17 |
# File 'app/models/spree/order_routing/strategy/base.rb', line 15 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.
21 22 23 |
# File 'app/models/spree/order_routing/strategy/base.rb', line 21 def self.display_name I18n.t("spree.order_routing.strategies.#{name.demodulize.underscore}", default: name.demodulize.titleize) end |
Instance Method Details
#for_allocation ⇒ Array<Spree::Stock::Package>
30 31 32 |
# File 'app/models/spree/order_routing/strategy/base.rb', line 30 def for_allocation raise NotImplementedError, "#{self.class} must implement #for_allocation" end |
#for_cancellation ⇒ Object
43 44 45 |
# File 'app/models/spree/order_routing/strategy/base.rb', line 43 def for_cancellation raise NotImplementedError, "#{self.class} must implement #for_cancellation" end |
#for_release ⇒ Object
39 40 41 |
# File 'app/models/spree/order_routing/strategy/base.rb', line 39 def for_release raise NotImplementedError, "#{self.class} must implement #for_release" end |
#for_sale(fulfillment:) ⇒ Object
35 36 37 |
# File 'app/models/spree/order_routing/strategy/base.rb', line 35 def for_sale(fulfillment:) raise NotImplementedError, "#{self.class} must implement #for_sale" end |