mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Refactoring conditional logic
Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
parent
2d74ed49f4
commit
0ae81a2124
1 changed files with 3 additions and 3 deletions
|
@ -4,9 +4,9 @@ module ActiveModel
|
|||
module Validations
|
||||
class ConfirmationValidator < EachValidator
|
||||
def validate_each(record, attribute, value)
|
||||
confirmed = record.send(:"#{attribute}_confirmation")
|
||||
return if confirmed.nil? || value == confirmed
|
||||
record.errors.add(attribute, :confirmation, options)
|
||||
if (confirmed = record.send("#{attribute}_confirmation")) && (value != confirmed)
|
||||
record.errors.add(attribute, :confirmation, options)
|
||||
end
|
||||
end
|
||||
|
||||
def setup(klass)
|
||||
|
|
Loading…
Reference in a new issue