Implement PopulateMatchBelow Interactor & Organizer
This commit is contained in:
parent
d2f5d3594e
commit
fc69c6e6e6
|
|
@ -14,7 +14,7 @@ class MatchesController < ApplicationController
|
|||
def update
|
||||
new_state = match_params['state']
|
||||
if new_state == 'finished'
|
||||
PlayoffStageService.populate_match_below(@match) unless @match.group_match?
|
||||
PopulateMatchBelowAndSave.call(match:@match) unless @match.group_match?
|
||||
end
|
||||
if @match.update(match_params)
|
||||
render json: @match
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class PopulateMatchBelow
|
||||
include Interactor
|
||||
|
||||
def call
|
||||
match = context.match
|
||||
begin
|
||||
PlayoffStageService.populate_match_below(match)
|
||||
context.object_to_save = match
|
||||
rescue StandardError
|
||||
context.fail!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class PopulateMatchBelowAndSave
|
||||
include Interactor::Organizer
|
||||
|
||||
organize PopulateMatchBelow, SaveApplicationRecordObject
|
||||
end
|
||||
Loading…
Reference in New Issue