Sha256: bf42b9f4c9938a7896b8d3ed2064028a02d7735c3a23fbc36add29561f18a628

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

module Pageflow
  # @api private
  class CustomizedTheme < SimpleDelegator
    def initialize(theme, overrides, files)
      super(theme)
      @options = __getobj__.options.deep_merge(overrides || {})
      @files = files
    end

    attr_reader :options, :files

    def self.find(entry:, theme:)
      build(
        entry: entry,
        theme: theme,
        theme_customization: Pageflow.theme_customizations.get(
          account: entry.account,
          entry_type_name: entry.type_name
        )
      )
    end

    def self.build(entry:, theme:, theme_customization:)
      config = Pageflow.config_for(entry)

      new(theme,
          config.transform_theme_customization_overrides.call(
            theme_customization.overrides,
            entry: entry,
            theme: theme
          ),
          config.transform_theme_customization_files.call(
            theme_customization.selected_files.transform_values(&:urls),
            entry: entry,
            theme: theme
          ))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pageflow-15.8.0 app/models/pageflow/customized_theme.rb