mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
56 lines
834 B
Ruby
56 lines
834 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ThemeSettingsSerializer < ApplicationSerializer
|
|
attributes :setting, :type, :default, :value, :description, :valid_values,
|
|
:list_type, :textarea
|
|
|
|
def setting
|
|
object.name
|
|
end
|
|
|
|
def type
|
|
object.type_name
|
|
end
|
|
|
|
def default
|
|
object.default
|
|
end
|
|
|
|
def value
|
|
object.value
|
|
end
|
|
|
|
def description
|
|
object.description
|
|
end
|
|
|
|
def valid_values
|
|
object.choices
|
|
end
|
|
|
|
def include_valid_values?
|
|
object.type == ThemeSetting.types[:enum]
|
|
end
|
|
|
|
def include_description?
|
|
object.description.present?
|
|
end
|
|
|
|
def list_type
|
|
object.list_type
|
|
end
|
|
|
|
def include_list_type?
|
|
object.type == ThemeSetting.types[:list]
|
|
end
|
|
|
|
def textarea
|
|
object.textarea
|
|
end
|
|
|
|
def include_textarea?
|
|
object.type == ThemeSetting.types[:string]
|
|
end
|
|
|
|
end
|