debian-mirror-gitlab/lib/gitlab/ci/config/entry/attributable.rb

28 lines
623 B
Ruby
Raw Normal View History

2016-09-13 17:45:13 +05:30
module Gitlab
module Ci
class Config
2017-08-17 22:00:37 +05:30
module Entry
2016-09-13 17:45:13 +05:30
module Attributable
extend ActiveSupport::Concern
class_methods do
def attributes(*attributes)
attributes.flatten.each do |attribute|
2018-03-17 18:26:18 +05:30
if method_defined?(attribute)
raise ArgumentError, 'Method already defined!'
end
2016-09-13 17:45:13 +05:30
define_method(attribute) do
return unless config.is_a?(Hash)
config[attribute]
end
end
end
end
end
end
end
end
end