Class: Cats::Core::OfferItem

Inherits:
ApplicationRecord show all
Defined in:
app/models/cats/core/offer_item.rb

Instance Method Summary collapse

Instance Method Details

#mark_as_winner(rank) ⇒ Object

Raises:

  • (StandardError)


13
14
15
16
17
18
19
# File 'app/models/cats/core/offer_item.rb', line 13

def mark_as_winner(rank)
  raise(StandardError, "Offer item already marked as winner.") if winner

  self.rank = rank
  self.winner = true
  save!
end

#validate_rank_is_set_for_winnerObject



21
22
23
24
25
# File 'app/models/cats/core/offer_item.rb', line 21

def validate_rank_is_set_for_winner
  return if rank

  errors.add(:winner, "cannot be set for a non-ranked offer item.") if winner
end