Class: TestHooks::BaseService

Inherits:
Object
  • Object
show all
Includes:
BaseServiceUtility
Defined in:
app/services/test_hooks/base_service.rb

Direct Known Subclasses

ProjectService, SystemService

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(hook, current_user, trigger) ⇒ BaseService

Returns a new instance of BaseService.


9
10
11
12
13
# File 'app/services/test_hooks/base_service.rb', line 9

def initialize(hook, current_user, trigger)
  @hook = hook
  @current_user = current_user
  @trigger = trigger
end

Instance Attribute Details

#current_userObject

Returns the value of attribute current_user


7
8
9
# File 'app/services/test_hooks/base_service.rb', line 7

def current_user
  @current_user
end

#hookObject

Returns the value of attribute hook


7
8
9
# File 'app/services/test_hooks/base_service.rb', line 7

def hook
  @hook
end

#triggerObject

Returns the value of attribute trigger


7
8
9
# File 'app/services/test_hooks/base_service.rb', line 7

def trigger
  @trigger
end

Instance Method Details

#executeObject


15
16
17
18
19
20
21
22
# File 'app/services/test_hooks/base_service.rb', line 15

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)
end