]> source.dussan.org Git - redmine.git/commitdiff
Wrap conditions with a single if new_record?.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 15 Jan 2017 12:58:07 +0000 (12:58 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 15 Jan 2017 12:58:07 +0000 (12:58 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@16201 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/user_preference.rb

index b2d336a20b005b6a4fd1065c89d059c69500a8e1..41c0f0b4b1c01f7c750d0ef3895113ff7d235dd4 100644 (file)
@@ -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