2018-11-29 06:44:48 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Config
|
|
|
|
module Entry
|
|
|
|
module Attributable
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
class_methods do
|
|
|
|
def attributes(*attributes)
|
|
|
|
attributes.flatten.each do |attribute|
|
|
|
|
if method_defined?(attribute)
|
2020-03-06 10:08:05 -05:00
|
|
|
raise ArgumentError, "Method '#{attribute}' already defined in '#{name}'"
|
2018-11-29 06:44:48 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
define_method(attribute) do
|
|
|
|
return unless config.is_a?(Hash)
|
|
|
|
|
|
|
|
config[attribute]
|
|
|
|
end
|
2019-08-13 05:47:30 -04:00
|
|
|
|
|
|
|
define_method("has_#{attribute}?") do
|
|
|
|
config.is_a?(Hash) && config.key?(attribute)
|
|
|
|
end
|
2018-11-29 06:44:48 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|