Sha256: daf09a535f74cf59a578e47bfa67c2ef82ae9acf11be62c4fdc2199d8c2dba8e
Contents?: true
Size: 1.16 KB
Versions: 35
Compression:
Stored size: 1.16 KB
Contents
require 'active_model' require 'active_support/concern' require 'active_support/core_ext/array/wrap' require 'polyblock/validators/polyblock_presence_validator' module Polyblock module Validators extend ActiveSupport::Concern included do extend HelperMethods include HelperMethods end module ClassMethods def validates_polyblock(*attributes) options = attributes.extract_options!.dup Polyblock::Validators.constants.each do |constant| if constant.to_s =~ /\APolyblock(.+)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 = Polyblock::Validators.const_get(constant.to_s).helper_method_name send(method_name, attributes, local_options.merge(conditional_options)) end end end end end end end end
Version data entries
35 entries across 35 versions & 1 rubygems