mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 13:41:31 +08:00
fb0e656cb7
Why this change? One Ruby class per file improves readability
18 lines
372 B
Ruby
18 lines
372 B
Ruby
# 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
|