gitlab-org--gitlab-foss/lib/gitlab/config/entry/attributable.rb
Kamil Trzciński 583544d089 Require stage: to be set with needs:
Since we are unsure what would be the behavior of `stage:`
when we work on DAG. Let's make `stage:` to be required
today with `needs:`.
2019-08-13 11:47:30 +02:00

31 lines
729 B
Ruby

# 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)
raise ArgumentError, 'Method already defined!'
end
define_method(attribute) do
return unless config.is_a?(Hash)
config[attribute]
end
define_method("has_#{attribute}?") do
config.is_a?(Hash) && config.key?(attribute)
end
end
end
end
end
end
end
end