Class: Jumbotron::Services::Canonical::EnsureSeason

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

Instance Method Summary collapse

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
18
# File 'app/services/jumbotron/services/canonical/ensure_season.rb', line 10

def call
  context.season = Season.find_or_create_by!(league_id: league.id, name: year.to_s)
rescue ActiveRecord::RecordInvalid => e
  context.fail!(
    application_error: Jumbotron::Errors::Canonical::MutationFailedError.new(
      details: { message: e.message }
    )
  )
end