Class: TestHooks::BaseService
- Inherits:
-
Object
- Object
- TestHooks::BaseService
- Includes:
- BaseServiceUtility
- Defined in:
- app/services/test_hooks/base_service.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#current_user ⇒ Object
Returns the value of attribute current_user.
-
#hook ⇒ Object
Returns the value of attribute hook.
-
#trigger ⇒ Object
Returns the value of attribute trigger.
Instance Method Summary collapse
- #error(message) ⇒ Object
- #execute ⇒ Object
-
#initialize(hook, current_user, trigger) ⇒ BaseService
constructor
A new instance of BaseService.
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
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_user ⇒ Object
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 |
#hook ⇒ Object
Returns the value of attribute hook.
7 8 9 |
# File 'app/services/test_hooks/base_service.rb', line 7 def hook @hook end |
#trigger ⇒ Object
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
#error(message) ⇒ Object
27 28 29 |
# File 'app/services/test_hooks/base_service.rb', line 27 def error() ServiceResponse.error(message: ) end |
#execute ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# 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, force: true) rescue ArgumentError => e error(e.) end |