mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Freeze options so we raise an error when people modify it in place.
This commit is contained in:
@@ -118,11 +118,13 @@ module ActiveModel
|
||||
# end
|
||||
#
|
||||
def validate(*args, &block)
|
||||
options = args.last
|
||||
if options.is_a?(Hash) && options.key?(:on)
|
||||
options = args.extract_options!
|
||||
if options.key?(:on)
|
||||
options = options.dup
|
||||
options[:if] = Array.wrap(options[:if])
|
||||
options[:if] << "validation_context == :#{options[:on]}"
|
||||
end
|
||||
args << options
|
||||
set_callback(:validate, *args, &block)
|
||||
end
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ module ActiveModel #:nodoc:
|
||||
|
||||
# Accepts options that will be made available through the +options+ reader.
|
||||
def initialize(options)
|
||||
@options = options
|
||||
@options = options.freeze
|
||||
end
|
||||
|
||||
# Return the kind for this validator.
|
||||
|
||||
Reference in New Issue
Block a user