Retrospring/lib/use_case/data_export/theme.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
614 B
Ruby
Raw Normal View History

2022-12-07 23:20:45 -08:00
# frozen_string_literal: true
module UseCase
module DataExport
class Theme < UseCase::DataExport::Base
include ThemeHelper
MODEL_FIELDS = %i[id user_id created_at updated_at].freeze
2022-12-07 23:20:45 -08:00
def files
return {} unless user.theme
{
"theme.json" => json_file!(
theme: theme_data,
),
2022-12-07 23:20:45 -08:00
}
end
def theme_data
{}.tap do |obj|
(column_names(::Theme) - MODEL_FIELDS).each do |field|
obj[field] = "##{get_hex_color_from_theme_value(user.theme[field])}"
2022-12-07 23:20:45 -08:00
end
end
end
end
end
end