mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Refactor callback setup in to use lambda instead of eval
This commit is contained in:
parent
79c491e838
commit
291f64469f
2 changed files with 5 additions and 3 deletions
|
@ -156,7 +156,7 @@ module ActiveModel
|
|||
if options.key?(:on)
|
||||
options = options.dup
|
||||
options[:if] = Array(options[:if])
|
||||
options[:if].unshift lambda { |o|
|
||||
options[:if].unshift ->(o) {
|
||||
Array(options[:on]).include?(o.validation_context)
|
||||
}
|
||||
end
|
||||
|
|
|
@ -58,7 +58,7 @@ module ActiveModel
|
|||
if options.is_a?(Hash) && options[:on]
|
||||
options[:if] = Array(options[:if])
|
||||
options[:on] = Array(options[:on])
|
||||
options[:if].unshift lambda { |o|
|
||||
options[:if].unshift ->(o) {
|
||||
options[:on].include? o.validation_context
|
||||
}
|
||||
end
|
||||
|
@ -98,7 +98,9 @@ module ActiveModel
|
|||
options[:if] = Array(options[:if])
|
||||
if options[:on]
|
||||
options[:on] = Array(options[:on])
|
||||
options[:if].unshift("#{options[:on]}.include? self.validation_context")
|
||||
options[:if].unshift ->(o) {
|
||||
options[:on].include? o.validation_context
|
||||
}
|
||||
end
|
||||
set_callback(:validation, :after, *(args << options), &block)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue