24 lines
584 B
Ruby
24 lines
584 B
Ruby
# frozen_string_literal: true
|
|
|
|
module TestHooks
|
|
class BaseService
|
|
include BaseServiceUtility
|
|
|
|
attr_accessor :hook, :current_user, :trigger
|
|
|
|
def initialize(hook, current_user, trigger)
|
|
@hook = hook
|
|
@current_user = current_user
|
|
@trigger = trigger
|
|
end
|
|
|
|
def execute
|
|
trigger_key = hook.class.triggers.key(trigger.to_sym)
|
|
|
|
return error('Testing not available for this hook') if trigger_key.nil? || data.blank?
|
|
return error(data[:error]) if data[:error].present?
|
|
|
|
hook.execute(data, trigger_key, force: true)
|
|
end
|
|
end
|
|
end
|