Method: ActiveModel::EachValidator#initialize

Defined in:
lib/active_model/validator.rb

#initialize(options) ⇒ EachValidator

Returns a new validator instance. All options will be available via the options reader, however the :attributes option will be removed and instead be made available through the attributes reader.

Raises:

  • (ArgumentError)


140
141
142
143
144
145
# File 'lib/active_model/validator.rb', line 140

def initialize(options)
  @attributes = Array(options.delete(:attributes))
  raise ArgumentError, ":attributes cannot be blank" if @attributes.empty?
  super
  check_validity!
end