Class Index [+]

Quicksearch

ActiveModel::Validations::AcceptanceValidator

Public Class Methods

new(options) click to toggle source
   # File lib/active_model/validations/acceptance.rb, line 5
5:       def initialize(options)
6:         super(options.reverse_merge(:allow_nil => true, :accept => "1"))
7:       end

Public Instance Methods

setup(klass) click to toggle source
    # File lib/active_model/validations/acceptance.rb, line 15
15:       def setup(klass)
16:         attr_readers = attributes.reject { |name| klass.attribute_method?(name) }
17:         attr_writers = attributes.reject { |name| klass.attribute_method?("#{name}=") }
18:         klass.send(:attr_reader, *attr_readers)
19:         klass.send(:attr_writer, *attr_writers)
20:       end
validate_each(record, attribute, value) click to toggle source
    # File lib/active_model/validations/acceptance.rb, line 9
 9:       def validate_each(record, attribute, value)
10:         unless value == options[:accept]
11:           record.errors.add(attribute, :accepted, options.except(:accept, :allow_nil))
12:         end
13:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.