DEV: Refactor subclasses in ThemeSettingsManager to individual files (#25605)

Why this change?

One Ruby class per file improves readability
This commit is contained in:
Alan Guo Xiang Tan
2024-02-08 12:59:52 +08:00
committed by GitHub
parent 7ce76143ac
commit fb0e656cb7
12 changed files with 197 additions and 185 deletions

View File

@ -0,0 +1,17 @@
# frozen_string_literal: true
class ThemeSettingsManager::Objects < ThemeSettingsManager
def value
has_record? ? db_record.json_value : default.map!(&:deep_stringify_keys)
end
def value=(objects)
# TODO: Validate the objects against the schema
record = has_record? ? db_record : create_record!
record.json_value = objects
record.save!
theme.reload
record.json_value
end
end