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

Make parent_validations work

parent 7398edf6
...@@ -11,8 +11,6 @@ module Gitlab ...@@ -11,8 +11,6 @@ module Gitlab
include ::Gitlab::Config::Entry::Validatable include ::Gitlab::Config::Entry::Validatable
validations do validations do
validates :config, type: Hash
validate do validate do
each_unmatched_job do |name| each_unmatched_job do |name|
errors.add(name, 'config should implement a script: or a trigger: keyword') errors.add(name, 'config should implement a script: or a trigger: keyword')
......
...@@ -10,17 +10,21 @@ module Gitlab ...@@ -10,17 +10,21 @@ module Gitlab
class ComposableHash < ::Gitlab::Config::Entry::Node class ComposableHash < ::Gitlab::Config::Entry::Node
include ::Gitlab::Config::Entry::Validatable include ::Gitlab::Config::Entry::Validatable
validations do def self.parent_validations
validates :config, type: Hash validations do
validates :config, type: Hash
end
end end
parent_validations
def compose!(deps = nil) def compose!(deps = nil)
super do super do
@config.each do |name, config| @config.each do |name, config|
entry_class = composable_class(name, config) entry_class = composable_class(name, config)
raise ArgumentError, 'Missing Composable class' unless entry_class 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) factory = ::Gitlab::Config::Entry::Factory.new(entry_class)
.value(config || {}) .value(config || {})
...@@ -36,7 +40,7 @@ module Gitlab ...@@ -36,7 +40,7 @@ module Gitlab
end end
end end
def composable_class(name = nil, config = nil) def composable_class(name, config)
opt(:composable_class) opt(:composable_class)
end end
end end
......
...@@ -20,6 +20,8 @@ module Gitlab ...@@ -20,6 +20,8 @@ module Gitlab
yield(self) if block_given? yield(self) if block_given?
self.class.parent_validations if self.class.respond_to?(:parent_validations)
self.class.aspects.to_a.each do |aspect| self.class.aspects.to_a.each do |aspect|
instance_exec(&aspect) instance_exec(&aspect)
end end
......
...@@ -39,8 +39,6 @@ module Gitlab ...@@ -39,8 +39,6 @@ module Gitlab
end end
end end
private
def validations(&block) def validations(&block)
(@validations ||= []).append(block) (@validations ||= []).append(block)
end 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