16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/polygallery/validators.rb', line 16
def validates_polygallery(*attributes)
options = attributes..dup
Polygallery::Validators.constants.each do |constant|
if constant.to_s =~ /\APolygallery(.+)Validator\Z/
validator_kind = $1.underscore.to_sym
if options.has_key?(validator_kind)
validator_options = options.delete(validator_kind)
validator_options = {} if validator_options == true
conditional_options = options.slice(:if, :unless)
Array.wrap(validator_options).each do |local_options|
method_name = Polygallery::Validators.const_get(constant.to_s).helper_method_name
send(method_name, attributes, local_options.merge(conditional_options))
end
end
end
end
end
|