1
0
Fork 0
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:
José Valim 2010-08-03 15:34:31 +02:00
parent f23bc8444b
commit 84081fcc54
2 changed files with 5 additions and 3 deletions

View file

@ -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

View file

@ -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.