From c988d6ca48870237232b7b218ac32ffc3ed9d2fe Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Mon, 5 Oct 2020 15:47:26 +0000 Subject: [PATCH] shorten long line of app/models/setting.rb git-svn-id: http://svn.redmine.org/redmine/trunk@20123 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/setting.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/models/setting.rb b/app/models/setting.rb index e71a9a0cf..64c2b8b49 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -85,11 +85,19 @@ class Setting < ActiveRecord::Base cattr_accessor :available_settings self.available_settings ||= {} - validates_uniqueness_of :name, :if => Proc.new {|setting| setting.new_record? || setting.name_changed?} + validates_uniqueness_of( + :name, + :if => Proc.new do |setting| + setting.new_record? || setting.name_changed? + end + ) validates_inclusion_of :name, :in => Proc.new {available_settings.keys} - validates_numericality_of :value, :only_integer => true, :if => Proc.new { |setting| - (s = available_settings[setting.name]) && s['format'] == 'int' - } + validates_numericality_of( + :value, :only_integer => true, + :if => Proc.new do |setting| + (s = available_settings[setting.name]) && s['format'] == 'int' + end + ) # Hash used to cache setting values @cached_settings = {} -- 2.39.5