Remove flag argument anti-pattern from Shop::OrderCyclesList

Co-authored-by: Maikel <maikel@email.org.au>
This commit is contained in:
Cillian O'Ruanaidh
2022-06-29 11:48:55 +01:00
committed by Filipe
parent da3eea6005
commit 61bbf0714e

View File

@@ -4,11 +4,13 @@
module Shop
class OrderCyclesList
def self.active_for(distributor, customer)
new(distributor, customer).call(ready_for_checkout: false)
new(distributor, customer).call
end
def self.ready_for_checkout_for(distributor, customer)
new(distributor, customer).call(ready_for_checkout: true)
return OrderCycle.none if !distributor.ready_for_checkout?
new(distributor, customer).call
end
def initialize(distributor, customer)
@@ -16,9 +18,7 @@ module Shop
@customer = customer
end
def call(ready_for_checkout:)
return OrderCycle.none if ready_for_checkout && !@distributor.ready_for_checkout?
def call
order_cycles = OrderCycle.with_distributor(@distributor).active
.order(@distributor.preferred_shopfront_order_cycle_order).to_a