mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Freeze options so we raise an error when people modify it in place.
This commit is contained in:
parent
f23bc8444b
commit
84081fcc54
2 changed files with 5 additions and 3 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue