module Polygallery::Validators::ClassMethods
Public Instance Methods
validates_polygallery(*attributes)
click to toggle source
# File lib/polygallery/validators.rb, line 16 def validates_polygallery(*attributes) options = attributes.extract_options!.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