Move eventable types constant to a helper

This moves API::ResourceLabelEventsHelpers::EVENTABLE_TYPES to a class
method in a separate helper module, allowing EE to redefine it without
having to directly modify the source code.
This commit is contained in:
Yorick Peterse 2019-02-26 17:07:32 +01:00
parent 6402880c70
commit 6c9e26a2a0
No known key found for this signature in database
GPG Key ID: EDD30D2BEB691AC9
2 changed files with 14 additions and 3 deletions

View File

@ -0,0 +1,13 @@
# frozen_string_literal: true
module API
module Helpers
module ResourceLabelEventsHelpers
def self.eventable_types
# This is a method instead of a constant, allowing EE to more easily
# extend it.
[Issue, MergeRequest]
end
end
end
end

View File

@ -7,9 +7,7 @@ module API
before { authenticate! }
EVENTABLE_TYPES = [Issue, MergeRequest].freeze
EVENTABLE_TYPES.each do |eventable_type|
Helpers::ResourceLabelEventsHelpers.eventable_types.each do |eventable_type|
parent_type = eventable_type.parent_class.to_s.underscore
eventables_str = eventable_type.to_s.underscore.pluralize