提交 84081fcc 编写于 作者: J José Valim

Freeze options so we raise an error when people modify it in place.

上级 f23bc844
......@@ -118,11 +118,13 @@ def validates_each(*attr_names, &block)
# 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 @@ def self.kind
# 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.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册