Class: Spree::OrderRouting::Rules::DefaultLocation

Inherits:
Spree::OrderRoutingRule show all
Defined in:
app/models/spree/order_routing/rules/default_location.rb

Overview

Ranks the StockLocation marked ‘default: true` at 0 and others at 1. Provides a deterministic baseline so the reducer always has a winner once higher-priority rules abstain or tie.

Instance Method Summary collapse

Instance Method Details

#rank(_order, locations) ⇒ Object



8
9
10
11
12
# File 'app/models/spree/order_routing/rules/default_location.rb', line 8

def rank(_order, locations)
  locations.map do |loc|
    LocationRanking.new(location: loc, rank: loc.default? ? 0 : 1)
  end
end