aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorSubba Rao Pasupuleti <subbarao.pasupuleti@gmail.com>2010-08-31 17:57:39 -0400
committerJosé Valim <jose.valim@gmail.com>2010-09-01 14:00:26 +0200
commit0ae81a21243961f4d2481e9b87e3c807291d21a9 (patch)
tree7f8f2e49b28ec3ab8353fa445d17cad5b0e92744 /activemodel/lib
parent2d74ed49f4513572b102ce82696a6f62335a1841 (diff)
downloadrails-0ae81a21243961f4d2481e9b87e3c807291d21a9.tar.gz
rails-0ae81a21243961f4d2481e9b87e3c807291d21a9.tar.bz2
rails-0ae81a21243961f4d2481e9b87e3c807291d21a9.zip
Refactoring conditional logic
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/validations/confirmation.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/activemodel/lib/active_model/validations/confirmation.rb b/activemodel/lib/active_model/validations/confirmation.rb
index a31966d0c2..2c8a840124 100644
--- a/activemodel/lib/active_model/validations/confirmation.rb
+++ b/activemodel/lib/active_model/validations/confirmation.rb
@@ -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)