class V1::MatchScoreboardController

Controller for match scoreboards

Public Instance Methods

show() click to toggle source

Render the match score

  • Params

  • Response

# File app/controllers/v1/match_scoreboard_controller.rb, line 17
def show
  render json: V1::MatchScoreboardSerializer.new(@match, root: false)
end
update() click to toggle source

Execute an action by calling Match#play_match!

  • Params

    • :action - action such as :win_game

    • :version - match play version number

    • :team - id of a Team to win a game

    • :player - id of a Player to serve or win a game

  • Response

# File app/controllers/v1/match_scoreboard_controller.rb, line 29
def update
  request_params = match_scoreboard_params
  action = request_params[:action].to_sym
  version = request_params[:version]
  team_id = request_params[:team]
  player_id = request_params[:player] unless team_id

  play_params = {}
  play_params[:version] = version if version
  play_params[:opponent] =
    if team_id
      Team.find(team_id) if team_id
    elsif player_id
      Player.find(player_id) if player_id
    end

  play_match {
    @match.play_match!(action, play_params)
  }
end