Class: Spree::StockReservation
- Inherits:
-
Object
- Object
- Spree::StockReservation
- Defined in:
- app/models/spree/stock_reservation.rb
Class Method Summary collapse
-
.ttl_for(order) ⇒ Object
Resolves the reservation TTL: per-Store preference if set, otherwise the global Spree::Config.
Instance Method Summary collapse
Class Method Details
.ttl_for(order) ⇒ Object
Resolves the reservation TTL: per-Store preference if set, otherwise the global Spree::Config. Falls back to 10 minutes if both are unset (e.g. early-boot / fixture state).
32 33 34 35 36 |
# File 'app/models/spree/stock_reservation.rb', line 32 def self.ttl_for(order) minutes = order&.store&.preferred_stock_reservation_ttl_minutes minutes = Spree::Config[:default_stock_reservation_ttl_minutes] if minutes.blank? minutes.to_i.then { |m| m > 0 ? m : 10 }.minutes end |
Instance Method Details
#active? ⇒ Boolean
25 26 27 |
# File 'app/models/spree/stock_reservation.rb', line 25 def active? expires_at > Time.current end |