From ae99ecd54fce136022a55f89c2eb1be18ca86f58 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 15 Jan 2017 12:58:07 +0000 Subject: [PATCH] Wrap conditions with a single if new_record?. git-svn-id: http://svn.redmine.org/redmine/trunk@16201 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/user_preference.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb index b2d336a20..41c0f0b4b 100644 --- a/app/models/user_preference.rb +++ b/app/models/user_preference.rb @@ -36,14 +36,16 @@ class UserPreference < ActiveRecord::Base def initialize(attributes=nil, *args) super - if new_record? && !(attributes && attributes.key?(:hide_mail)) - self.hide_mail = Setting.default_users_hide_mail? - end - if new_record? && !(attributes && attributes.key?(:time_zone)) - self.time_zone = Setting.default_users_time_zone - end - if new_record? && !(attributes && attributes.key?(:no_self_notified)) - self.no_self_notified = true + if new_record? + unless attributes && attributes.key?(:hide_mail) + self.hide_mail = Setting.default_users_hide_mail? + end + unless attributes && attributes.key?(:time_zone) + self.time_zone = Setting.default_users_time_zone + end + unless attributes && attributes.key?(:no_self_notified) + self.no_self_notified = true + end end self.others ||= {} end