Sha256: 9956e9e7bac44591e8285c5f24b28f08a8f1e85ebcf12a9d0fef54c32cdf9f50
Contents?: true
Size: 1.14 KB
Versions: 5
Compression:
Stored size: 1.14 KB
Contents
module Pageflow # Override theme options and upload theme files for an entry type on # a per account basis. # # @since 15.7 class ThemeCustomization < ApplicationRecord belongs_to :site serialize :overrides, coder: JSON serialize :selected_file_ids, coder: JSON has_many :uploaded_files, class_name: 'ThemeCustomizationFile' # Options that were passed to [ThemeCustomizations#update]. # # @return [Hash<Symbol, Object>] def overrides super&.deep_symbolize_keys || {} end # Theme customization files that have been assigned a role via # [ThemeCustomizations#update]. # # @return [Hash<Symbol, ThemeCustomizationFile>] def selected_files selected_file_ids.compact.transform_values do |id| selected_files_by_id[id] end end # @api private def entry_type Pageflow.config.entry_types.find_by_name!(entry_type_name) end private def selected_file_ids super&.deep_symbolize_keys || {} end def selected_files_by_id @selected_files_by_id ||= uploaded_files.where(id: selected_file_ids.values).index_by(&:id) end end end
Version data entries
5 entries across 5 versions & 1 rubygems