Commit 7eb70c63 authored by allison.browne's avatar allison.browne

Make parent_validations work

parent 7398edf6
......@@ -11,8 +11,6 @@ module Gitlab
include ::Gitlab::Config::Entry::Validatable
validations do
validates :config, type: Hash
validate do
each_unmatched_job do |name|
errors.add(name, 'config should implement a script: or a trigger: keyword')
......
......@@ -10,17 +10,21 @@ module Gitlab
class ComposableHash < ::Gitlab::Config::Entry::Node
include ::Gitlab::Config::Entry::Validatable
validations do
validates :config, type: Hash
def self.parent_validations
validations do
validates :config, type: Hash
end
end
parent_validations
def compose!(deps = nil)
super do
@config.each do |name, config|
entry_class = composable_class(name, config)
raise ArgumentError, 'Missing Composable class' unless entry_class
entry_class_name = entry_class.name.split('::').last.downcase
entry_class_name = entry_class.name.demodulize.underscore
factory = ::Gitlab::Config::Entry::Factory.new(entry_class)
.value(config || {})
......@@ -36,7 +40,7 @@ module Gitlab
end
end
def composable_class(name = nil, config = nil)
def composable_class(name, config)
opt(:composable_class)
end
end
......
......@@ -20,6 +20,8 @@ module Gitlab
yield(self) if block_given?
self.class.parent_validations if self.class.respond_to?(:parent_validations)
self.class.aspects.to_a.each do |aspect|
instance_exec(&aspect)
end
......
......@@ -39,8 +39,6 @@ module Gitlab
end
end
private
def validations(&block)
(@validations ||= []).append(block)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment