Sha256: d180c643bb99934e3f564d3acf301d851662568bfcc2992d38442fb097441cac

Contents?: true

Size: 1020 Bytes

Versions: 8

Compression:

Stored size: 1020 Bytes

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(
          site: entry.site,
          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

8 entries across 8 versions & 1 rubygems

Version Path
pageflow-17.0.4 app/models/pageflow/customized_theme.rb
pageflow-17.0.3 app/models/pageflow/customized_theme.rb
pageflow-17.0.2 app/models/pageflow/customized_theme.rb
pageflow-17.0.1 app/models/pageflow/customized_theme.rb
pageflow-17.0.0 app/models/pageflow/customized_theme.rb
pageflow-16.2.0 app/models/pageflow/customized_theme.rb
pageflow-16.1.0 app/models/pageflow/customized_theme.rb
pageflow-16.0.0 app/models/pageflow/customized_theme.rb