Sha256: c2d491bfb53d32cd3b03c0da9274885e5b69cde6934db1b3838c82464f102273

Contents?: true

Size: 438 Bytes

Versions: 35

Compression:

Stored size: 438 Bytes

Contents

module ActiveModel
  module Validations
    class RespondToValidator < EachValidator
      RESERVED_OPTIONS = [:if, :unless]
      def validate_each(record,attribute,value)
        responders = options.dup
        RESERVED_OPTIONS.each do |opt,should_apply| responders.delete(opt) end
        responders.each do |method,dummy|
          record.errors.add(attribute) unless value.respond_to? method
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
activevalidators-1.8.0 lib/active_model/validations/respond_to_validator.rb
activevalidators-1.7.1 lib/active_model/validations/respond_to_validator.rb
activevalidators-1.7.0 lib/active_model/validations/respond_to_validator.rb
activevalidators-1.6.0 lib/active_model/validations/respond_to_validator.rb
activevalidators-1.5.1 lib/active_model/validations/respond_to_validator.rb
activevalidators-1.5.0 lib/active_model/validations/respond_to_validator.rb
activevalidators-1.4.0 lib/active_model/validations/respond_to_validator.rb
activevalidators-1.3.0 lib/active_model/validations/respond_to_validator.rb
activevalidators-1.2.4 lib/active_model/validations/respond_to_validator.rb
activevalidators-1.2.3 lib/active_model/validations/respond_to_validator.rb
activevalidators-1.2.2 lib/active_model/validations/respond_to_validator.rb
activevalidators-1.2.1 lib/active_model/validations/respond_to_validator.rb
activevalidators-1.2.0 lib/active_model/validations/respond_to_validator.rb
activevalidators-1.1.0 lib/active_model/validations/respond_to_validator.rb
activevalidators-1.0.2 lib/active_model/validations/respond_to_validator.rb