Class: Jumbotron::Services::Public::ReadGame

Inherits:
CommandTower::Services::ApplicationService
  • Object
show all
Defined in:
app/services/jumbotron/services/public/read_game.rb

Constant Summary collapse

ASSOCIATIONS =
[
  :venue,
  :season_phase,
  :schedule_group,
  { league: :sport, season: :league, game_participants: :team }
].freeze

Instance Method Summary collapse

Instance Method Details

#callObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/services/jumbotron/services/public/read_game.rb', line 16

def call
  game = Game.includes(ASSOCIATIONS).find_by(id: game_id)
  if game.nil?
    context.fail!(
      application_error: Jumbotron::Errors::Public::NotFoundError.new(
        details: { code: "game_not_found", message: "game was not found" }
      )
    )
    return
  end

  context.game = game
end