Module: SpreeCmCommissioner::LineItemSeatSelection
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/spree_cm_commissioner/line_item_seat_selection.rb
Instance Method Summary collapse
-
#required_seat_selection? ⇒ Boolean
Caches the required_seat_selection flag from the trip in private_metadata.
Instance Method Details
#required_seat_selection? ⇒ Boolean
Caches the required_seat_selection flag from the trip in private_metadata.
Why cache? Most line items don’t have trips, so checking ‘product.trip.required_seat_selection` on every read would cause N+1 queries. Caching avoids this performance hit.
Behavior: The flag is set once at line item creation and remains immutable. This preserves the historical seat selection state of the order, even if the trip’s settings change later. We don’t have use cases requiring dynamic updates of this yet, so we keep it constant for simplicity and consistency.
21 22 23 24 25 |
# File 'app/models/concerns/spree_cm_commissioner/line_item_seat_selection.rb', line 21 def required_seat_selection? return false if ['required_seat_selection'].nil? ActiveModel::Type::Boolean.new.cast(['required_seat_selection']) end |