mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 19:29:34 +08:00
DEV: Refactor subclasses in ThemeSettingsManager
to individual files (#25605)
Why this change? One Ruby class per file improves readability
This commit is contained in:

committed by
GitHub

parent
7ce76143ac
commit
fb0e656cb7
17
lib/theme_settings_manager/enum.rb
Normal file
17
lib/theme_settings_manager/enum.rb
Normal file
@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ThemeSettingsManager::Enum < ThemeSettingsManager
|
||||
def value
|
||||
val = super
|
||||
match = choices.find { |choice| choice == val || choice.to_s == val }
|
||||
match || val
|
||||
end
|
||||
|
||||
def is_valid_value?(new_value)
|
||||
choices.include?(new_value) || choices.map(&:to_s).include?(new_value)
|
||||
end
|
||||
|
||||
def choices
|
||||
@opts[:choices]
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user