summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorAlexis Reigel <alexis.reigel.ext@siemens.com>2017-12-08 14:17:15 +0100
committerAlexis Reigel <alexis.reigel.ext@siemens.com>2018-01-17 09:55:00 +0100
commitfaadd9e0e4edcb332b41aceabd6c03a796e11978 (patch)
tree3fc3f2dec56e9e6c447888efd0e2759c55d4123b /app/models
parentf99b0cc5853f10e07a8ed60caa40c07a4c677d6f (diff)
downloadgitlab-ce-faadd9e0e4edcb332b41aceabd6c03a796e11978.tar.gz
use class reader instead of dynamic constant
Diffstat (limited to 'app/models')
-rw-r--r--app/models/concerns/triggerable_hooks.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/app/models/concerns/triggerable_hooks.rb b/app/models/concerns/triggerable_hooks.rb
index 4f2c8102204..ec0ed3b795a 100644
--- a/app/models/concerns/triggerable_hooks.rb
+++ b/app/models/concerns/triggerable_hooks.rb
@@ -17,8 +17,10 @@ module TriggerableHooks
class_methods do
attr_reader :triggerable_hooks
+ attr_reader :triggers
+
def hooks_for(trigger)
- callable_scopes = self::TRIGGERS.keys + [:all]
+ callable_scopes = triggers.keys + [:all]
return none unless callable_scopes.include?(trigger)
public_send(trigger) # rubocop:disable GitlabSecurity/PublicSend
@@ -28,9 +30,9 @@ module TriggerableHooks
def triggerable_hooks(hooks)
triggers = AVAILABLE_TRIGGERS.slice(*hooks)
- const_set('TRIGGERS', triggers)
+ @triggers = triggers
- self::TRIGGERS.each do |trigger, event|
+ triggers.each do |trigger, event|
scope trigger, -> { where(event => true) }
end
end