Class: SpreeCmCommissioner::VotingContestants::Advancer
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::VotingContestants::Advancer
- Includes:
- Spree::ServiceModule::Base
- Defined in:
- app/services/spree_cm_commissioner/voting_contestants/advancer.rb
Overview
Keeps one VotingContestant row in sync with the “next” round (another session or episode).
Flow (after update! on the current row):
-
**Elimination changed** (‘eliminated` toggled) and this row has an
advanced_to:-
Marking eliminated: validate reversion order (block if the advance chain continues in a later session or the next hop has votes), then remove only the immediate linked row in the destination session (if no votes). Unwind later rounds first, then earlier ones.
-
Un-eliminating:
create_or_update_destination_record(restore the linked row).
-
-
**Advance target changed** (
advanced_to_type/advanced_to_id):-
cleanup_previous_destination, then if still active and pointing somewhere,create_or_update_destination_recordat the new destination.
-
Linked row = the VotingContestant in the next session with the same show_contestant, advanced_from = this row’s voting_session.
Instance Method Summary collapse
Instance Method Details
#call(voting_contestant:, attributes:) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/services/spree_cm_commissioner/voting_contestants/advancer.rb', line 22 def call(voting_contestant:, attributes:) @voting_contestant = voting_contestant @attributes = attributes || {} ActiveRecord::Base.transaction do update_contestant sync_advancement end success(voting_contestant: @voting_contestant.reload) rescue StandardError => e failure(nil, e.) end |