32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/reactor/validations.rb', line 32
def inherited(subclass)
super(subclass)
mandatory_attrs = __mandatory_cms_attributes(subclass.name)
mandatory_attrs&.each do |attr|
subclass.send(:validates_presence_of, attr.to_sym, on: :release)
end
cms_attributes = __cms_attributes(subclass).values
array_attr = %w(linklist multienum)
array_attributes = cms_attributes.select { |attr| array_attr.include?(attr.attribute_type) }
array_attributes.each do |attr|
length_hash = {}
if attr.min_size && "linklist" != attr.attribute_type
length_hash[:minimum] = attr.min_size
end
length_hash[:maximum] = attr.max_size if attr.max_size
unless length_hash.empty?
subclass.send(:validates, attr.attribute_name.to_sym, length: length_hash, on: :release)
end
end
subclass
end
|