Class: SpreeCmCommissioner::VotingContestant

Inherits:
Base
  • Object
show all
Defined in:
app/models/spree_cm_commissioner/voting_contestant.rb

Constant Summary collapse

FIRESTORE_PUBLISHED_COLUMNS =

Republish the parent session's Firestore document whenever anything the show screen renders changes, so a reveal reaches every device without a pull-to-refresh.

%w[visible vote_number position eliminated].freeze

Instance Method Summary collapse

Instance Method Details

#advanced_from_nameObject



77
78
79
# File 'app/models/spree_cm_commissioner/voting_contestant.rb', line 77

def advanced_from_name
  [advanced_from&.episode&.name, advanced_from&.name].compact.join(' - ')
end

#advanced_to_nameObject



81
82
83
# File 'app/models/spree_cm_commissioner/voting_contestant.rb', line 81

def advanced_to_name
  [advanced_to&.episode&.name || advanced_to_episode&.name, advanced_to&.name].compact.join(' - ')
end

#hide!Object



73
74
75
# File 'app/models/spree_cm_commissioner/voting_contestant.rb', line 73

def hide!
  update!(visible: false)
end

#reveal!Object

revealed_at records the first reveal and is left in place by #hide! — it is a broadcast audit trail ("when did this contestant go on screen"), not a mirror of visible.



69
70
71
# File 'app/models/spree_cm_commissioner/voting_contestant.rb', line 69

def reveal!
  update!(visible: true, revealed_at: revealed_at || Time.current)
end

#special_rule_typeObject



63
64
65
# File 'app/models/spree_cm_commissioner/voting_contestant.rb', line 63

def special_rule_type
  (special_rules || {})['type']
end

#special_rule_type=(value) ⇒ Object



59
60
61
# File 'app/models/spree_cm_commissioner/voting_contestant.rb', line 59

def special_rule_type=(value)
  self.special_rules = value.present? ? { 'type' => value } : {}
end