class MatchPlay::RemoveLastChange

Class to remove the last scoring change. Removing the last scoring change may involve deleting games or sets, or changing attribute values.

Public Class Methods

new(match) click to toggle source
# File app/models/concerns/match_play.rb, line 340
def initialize(match)
  @match = match
end

Public Instance Methods

remove_last() click to toggle source

Execute :remove_last_change action by updating and/or deleting entities.

# File app/models/concerns/match_play.rb, line 347
def remove_last
  @save_list = []
  @destroy_list = []
  if match.team_winner
    remove_match_complete
  elsif match.last_set
    remove_last_set_change(match.last_set)
  end
  save_list.each(&:save!)
  destroy_list.each(&:destroy)
end