diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-18 00:09:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-18 00:09:08 +0300 |
commit | 496e357721b6b807573a35490ab2487dfa299cab (patch) | |
tree | b40b5252a3f3a8339e70f88b84c9ab5c1c6b44c6 /app/models/user_preference.rb | |
parent | b9b3924a96ef04cf1aa1b7570e2f69bfd8904602 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/user_preference.rb')
-rw-r--r-- | app/models/user_preference.rb | 69 |
1 files changed, 4 insertions, 65 deletions
diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb index bc2c6b526b8..c6ebd550daf 100644 --- a/app/models/user_preference.rb +++ b/app/models/user_preference.rb @@ -26,10 +26,10 @@ class UserPreference < ApplicationRecord ignore_columns :experience_level, remove_with: '14.10', remove_after: '2021-03-22' - attribute :tab_width, default: -> { Gitlab::TabWidth::DEFAULT } - attribute :time_display_relative, default: true - attribute :time_format_in_24h, default: false - attribute :render_whitespace_in_code, default: false + default_value_for :tab_width, value: Gitlab::TabWidth::DEFAULT, allows_nil: false + default_value_for :time_display_relative, value: true, allows_nil: false + default_value_for :time_format_in_24h, value: false, allows_nil: false + default_value_for :render_whitespace_in_code, value: false, allows_nil: false class << self def notes_filters @@ -59,67 +59,6 @@ class UserPreference < ApplicationRecord self[notes_filter_field_for(resource)] end - def tab_width - read_attribute(:tab_width) || self.class.column_defaults['tab_width'] - end - - def tab_width=(value) - if value.nil? - default = self.class.column_defaults['tab_width'] - super(default) - else - super(value) - end - end - - def time_display_relative - value = read_attribute(:time_display_relative) - return value unless value.nil? - - self.class.column_defaults['time_display_relative'] - end - - def time_display_relative=(value) - if value.nil? - default = self.class.column_defaults['time_display_relative'] - super(default) - else - super(value) - end - end - - def time_format_in_24h - value = read_attribute(:time_format_in_24h) - return value unless value.nil? - - self.class.column_defaults['time_format_in_24h'] - end - - def time_format_in_24h=(value) - if value.nil? - default = self.class.column_defaults['time_format_in_24h'] - super(default) - else - super(value) - end - end - - def render_whitespace_in_code - value = read_attribute(:render_whitespace_in_code) - return value unless value.nil? - - self.class.column_defaults['render_whitespace_in_code'] - end - - def render_whitespace_in_code=(value) - if value.nil? - default = self.class.column_defaults['render_whitespace_in_code'] - super(default) - else - super(value) - end - end - private def notes_filter_field_for(resource) |